Norman's Note 諾曼筆記

Norman's Note 諾曼筆記

JS Comparison 物件值的比較

可以用等號來判斷是不是同一個 reference

例如:

const a = { name: '' };
b = a;
c = b;
console.log(a === c); // true

Pass by value / Pass by reference

例如:

const a = { name: '' };
b = a;
c = b;

const { name } = c;
a.name = 'norman';

console.log({ name });
console.log({ c });