标签:区别 OLE == ash 循环 pre 数据类型 str 拷贝
var a = [0, 1, [2,3], 4], b = a; a[0] = 1; a[2][0] = 1; console.log(a); // [1,1,[1,3],4] console.log(b); // [1,1,[1,3],4]
var a = [0, 1, [2,3], 4], b = a.slice(); a[0] = 1; a[2][0] = 1; console.log(a); // [1,1,[1,3],4] console.log(b); // [0,1,[1,3],4]
var a = [0, 1, [2,3], 4], var b = a.concat(4,5); a[0] = 1; a[2][0] = 1; console.log(a); // [1,1,[1,3],4] console.log(b); // [0,1,[1,3],4,5]
var a = [0, 1, [2,3], 4], b = Object.assign([], a); a[0] = 1; a[2][0] = 1; console.log(a); // [1,1,[1,3],4] console.log(b); // [0,1,[1,3],4]
var a = [0, 1, [2,3], 4], b = [...a]; a[0] = 1; a[2][0] = 1; console.log(a); // [1,1,[1,3],4] console.log(b); // [0,1,[1,3],4]
标签:区别 OLE == ash 循环 pre 数据类型 str 拷贝
原文地址:https://www.cnblogs.com/alisadream/p/10185119.html