在数组指定位置插入元素可以splice() 方法
语法:array.splice(index,howmany,item1,.....,itemX)
例子:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2,0,"Lemon","Kiwi");
输出结果:[Banana,Orange,Lemon,Kiwi,Apple,Mango]
在数组指定位置插入元素可以splice() 方法
语法:array.splice(index,howmany,item1,.....,itemX)
例子:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2,0,"Lemon","Kiwi");
输出结果:[Banana,Orange,Lemon,Kiwi,Apple,Mango]