数组的深拷贝实现方式:
利用es6的扩展运算符(...)
var a = [1,2,3]
var b = a;
var c = [...a];
b.push(4);
c.push(5);
console.log(a);//[1,2,3,4]
console.log(b);//[1,2,3,4]
console.log(c);//[1,2,3,5]
数组的深拷贝实现方式:
利用es6的扩展运算符(...)
var a = [1,2,3]
var b = a;
var c = [...a];
b.push(4);
c.push(5);
console.log(a);//[1,2,3,4]
console.log(b);//[1,2,3,4]
console.log(c);//[1,2,3,5]