Question 15
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const a = { x: 1 };
const b = a;
const c = { x: 1 };
console.log(a === b, a === c, JSON.stringify(a) === JSON.stringify(c));
- A true false true Correct
- B true true true
- C false false true
- D true false false
Correct Answer: Option A
b refers to the same object as a; c is a different object with the same content, which only the string comparison sees.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!