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更值得使用,更好的性能和稳定性
{ Slice }
let sourceArr = [1, 2, 3]
let copyArr = []
copyArr = sourceArr.slice()
{ Concat }
let sourceArr = [1, 2, 3]
let copyArr = []
copyArr = sourceArr.concat()
{ 结论 }
concat更值得使用,更好的性能和稳定性
YiiLib 专注于: 专业Web开发教程和专业Web开发服务
Copyright © 2011 - 2024 YiiLib.com(YiiBlog.info) - Designed & Developed by Boy.Lee
留言