JavaScript 演练(7). 赋值与引用
/* 值类型 */ n1 = 123; n2 = n1; //赋值 n2 = 456; alert(n1); //123; n1 != n2 /* 对象类型 */ arr1 = [123]; arr2 = arr1; //引用 arr2[0] = 456; alert(arr1[0]); //456; arr1 === arr2
2022-04-06 03:59:08
/* 值类型 */ n1 = 123; n2 = n1; //赋值 n2 = 456; alert(n1); //123; n1 != n2 /* 对象类型 */ arr1 = [123]; arr2 = arr1; //引用 arr2[0] = 456; alert(arr1[0]); //456; arr1 === arr2