javascript-Array Dear 丶 2022-06-02 08:39 151阅读 0赞 > splice 剪切和替换功能 var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.splice(2, 0, "Lemon", "Kiwi"); //Banana,Orange,Lemon,Kiwi,Apple,Mango > array.splice(index,howmany,item1,.....,itemX) var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.splice(2, 1, "Lemon", "Kiwi"); //Banana,Orange,Lemon,Kiwi,Mango -------------------- var fruits = ["Banana", "Orange", "Apple", "Mango", "Kiwi"]; fruits.splice(2, 2); // Banana,Orange,Kiwi
还没有评论,来说两句吧...