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个元素
本文标题:11,arr.splice
本文链接:https://www.haomeiwen.com/subject/nqqbtktx.html
网友评论