What does accessing a.count print?
const a = { count: 1 };
const b = a;
b.count += 5;
console.log(a.count);Answer & explanation
Answer: 6
a and b reference the same object. Mutating through b is visible through a.
Practice objects & references with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
const a = { count: 1 };
const b = a;
b.count += 5;
console.log(a.count);Answer: 6
a and b reference the same object. Mutating through b is visible through a.