对象引用

输出是什么?

function checkAge(data) {
  if (data === { age: 18 }) {
    console.log('You are an adult!')
  } else if (data == { age: 18 }) {
    console.log('You are still an adult.')
  } else {
    console.log(`Hmm.. You don't have an age I guess`)
  }
}

checkAge({ age: 18 })
  • A: You are an adult!

  • B: You are still an adult.

  • C: Hmm.. You don't have an age I guess

输出是什么?

let person = { name: "Lydia" };
const members = [person];
person = null;

console.log(members);
  • A: null

  • B: [null]

  • C: [{}]

  • D: [{ name: "Lydia" }]

最后更新于