数组的深拷贝实现方式:
利用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]
本文标题:2018-06-14
本文链接:https://www.haomeiwen.com/subject/ulwyeftx.html
网友评论