Do you know what will be the output of this code?
JavaScript
const a = { n: 1 };
const b = a;
b.n = 2;
console.log(a.n);
Show answer and explanation
The answer is 2.
b = a copies a reference to the same object. There’s still only one object, so the change through b is visible through a.