$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #164

What is the output?

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