concat() 克隆数组

// 在 ES5 中克隆数组
var colors = [ "red", "green", "blue" ];
var clonedColors = colors.concat();
console.log(clonedColors); //"[red,green,blue]"

concat()方法的设计初衷是连接两个数组,如果调用时不传递参数就会返回当前函数的副本

猜你喜欢

转载自blog.csdn.net/yang295242361/article/details/82895228