What are the reasons for the emergence of the two results? JS reference type result

what is the reason for the emergence of the two results?

var arrs = [{ x: 1 }];
console.log(arrs); // [{ x: 2 }]
arrs[0].x = 2;
console.log(arrs);// [{ x: 2 }]
 console.log(arrs)
 [{x: 2}]


var arrs2 = [{ x: 1 }];
console.log(arrs2[0].x); // 1
arrs2[0].x = 2;
console.log(arrs2[0].x);// 2
Mar.04,2022

I'll show you something funny, and you'll know why

  

what the general browser console.log prints out is also a reference to the data, not a snapshot of the facts

Menu