Object values overriding

if i add value to a property of an object then same value is assigning to all objects with same id in type script.

Can you give us a code example, please? Also, beware copying the reference - that could cause this.

const obj1 = { val: 1 };
const obj2 = obj1;
obj2.val = 'pink flamingo';
console.log(obj1);
// { val: 'pink flamingo' }

Is this what is confusing you?

1 Like