11,arr.splice
2020-06-11 本文已影响0人
r8HZGEmq
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2,1,"Lemon","Kiwi");
// Banana,Orange,Lemon,Kiwi,Mango
index从“Banana”的左边0开始
1,表示要切除一个元素
然后在该空档处添加2个元素
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2,1,"Lemon","Kiwi");
// Banana,Orange,Lemon,Kiwi,Mango
index从“Banana”的左边0开始
1,表示要切除一个元素
然后在该空档处添加2个元素