splice()可向数组删除并加入新的元素。
语法
arrayObject.splice(index,howmany,element1,.....,elementX)
输出结果为:
Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Lene,Stale,Kai Jim,Borge
arr.splice(
2
,
1
,
"
Tove
"
)
输出结果为:
Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Tove,Kai Jim,Borge
arr.splice(
2
,
3
,
"
Tove
"
)
输出结果为:
Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Tove