PRACTICE / UNDERSTAND / REPEAT

JavaScript: Objects & references

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

20 questionsAnswers explainedFree · no login
Question 1 of 20
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.