splice() 方法用于添加或删除数组中的元素

demo 1

demo2

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2,1,"Lemon","Kiwi");

输出结果:
Banana,Orange,Lemon,Kiwi,Mango
posted @ 2021-11-03 11:17  盘思动  阅读(229)  评论(2编辑  收藏  举报