2017-07-11 23:26:17 0 评论 JavaScript Boy.Lee

javascript 数组复制Copy方法推荐

{ Slice }

let sourceArr = [1, 2, 3]
let copyArr = []
copyArr = sourceArr.slice()

 

{ Concat }

let sourceArr = [1, 2, 3]
let copyArr = []
copyArr = sourceArr.concat()

 

{ 结论 }

concat更值得使用,更好的性能和稳定性