Câu hỏi

Kết quả đoạn code sau là gì?

  function compareMembers(person1, person2 = person) {
    if (person1 !== person2) {
      console.log("Not the same!");
    } else {
      console.log("They are the same!");
    }
  }
  const person = { name: "Lydia" };
  compareMembers(person);
  • A: Not the same!
  • B: They are the same!
  • C: ReferenceError
  • D: SyntaxError

Câu trả lời

Đáp án: B

Object sẽ được truyền vào hàm theo reference. Khi chúng ta nói s...

Bạn cần đăng nhập để xem