splice() 方法用于添加或删除数组中的元素
demo 1
demo2
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2,1,"Lemon","Kiwi");
输出结果:
Banana,Orange,Lemon,Kiwi,Mango
- 可以对比php中array_splice用法:https://www.cnblogs.com/pansidong/p/10830969.html
相信坚持的力量,日复一日的习惯.