Why reassigning of an object have different value?

I know it sounds a bit stupid but I'm kinda stuck here.

let a={
let b=a;

Change property of a.

b;  //{name: "Cindy"}, b follows a exactly.

Add a property for a.

b; //{name: "Cindy", age: 20}, b still follows a.

Here's the problem, Now b doesn't follow a... it's now having a different value. WHY..?

b; // {name: "Cindy", age: 20}. b is different from a.

Read more here: https://stackoverflow.com/questions/66997585/why-reassigning-of-an-object-have-different-value

Content Attribution

This content was originally published by qqwenwenti at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: