Skip to content
Onsite

Output: Object.freeze an object, then mutate a nested property and a top-level property

EasyP2Output

What does this code print?

1const user = { name: 'Ada', address: { city: 'London' } };
2Object.freeze(user);
3user.name = 'Grace';
4user.address.city = 'Paris';
5console.log(user.name, user.address.city);
6console.log(Object.isFrozen(user), Object.isFrozen(user.address));
Saved automatically

One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).

Hints

Saved automatically