$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #78

What is logged?

const a = { n: 1 };
const b = { ...a };
b.n = 2;
console.log(a.n, b.n, a === b);
  1. 1 2 false
  2. 2 2 false
  3. 1 2 true
  4. 2 2 true
Spread makes a separate top-level object, so writing to b leaves a alone.
Play Problem Solving ▸