let kim={
a:1,
b:2
}
console.log(kim);
let tip=["a","b",kim];
console.log(tip);
kim.a=2;
console.log(tip);
console.log(kim);
output
>{a: 1, b: 2}
['a', 'b', {…}]0: "a"1: "b"2: {a: 2, b: 2}:length: 3[[Prototype]]: Array(0)
['a', 'b', {…}]0: "a"1: "b"2: {a: 2, b: 2}length: 3[[Prototype]]: Array(0)
{a: 2, b: 2}
expect
{a: 1, b: 2}
['a', 'b', {…}]0: "a"1: "b"2: {**a: 1**, b: 2}:length: 3[[Prototype]]: Array(0)
['a', 'b', {…}]0: "a"1: "b"2: {a: 2, b: 2}length: 3[[Prototype]]: Array(0)
{a: 2, b: 2}
Kim.a was changed 1 to 2 after first tip print, but first tip print is changed 2 before kim.a changed. What mechanism is at work here?