What is the output?
const o = { a: 1 };
const p = o;
p.a = 2;
console.log(o.a);
- 2
- 1
- undefined
- Error
Both names reference the same object, so the mutation is visible through either.
Play Problem Solving ▸
const o = { a: 1 };
const p = o;
p.a = 2;
console.log(o.a);