PRACTICE / UNDERSTAND / REPEAT

JavaScript practice question

Practice objects & references with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

1 questionAnswers explainedFree · no login

Try this question

Objects & references · MCQQuestion link ↗

What does accessing a.count print?

const a = { count: 1 };
const b = a;
b.count += 5;
console.log(a.count);
Choose one answer
Answer & explanation

Answer: 6

a and b reference the same object. Mutating through b is visible through a.