0

Why when we rewrite the value of the method foo of the nested object s it's also rewrites the original object z method foo?

Explaine someone, please why it does and how to prevent it from rewrite?

const z = { foo: 'bar' };
const s = z;
s.foo = 'baz'; 
s == z // true
Max Wolfen
  • 1,923
  • 6
  • 24
  • 42

0 Answers0