📜  关键字中的 javascript - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:37.111000             🧑  作者: Mango

代码示例1
const person = { name: 'Nick', lastName: 'Coolguy', yearBorn: 1998 };

console.log('yearBorn' in person); // expected output: true

delete person.yearBorn;
if ('yearBorn' in person === false) {
  person.yearBorn = 2000;
}

console.log(person.yearBorn); // expected output: "2000"