js中array(数组)对象的splice方法的详解

 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

转载于:https://www.cnblogs.com/xcj1989/archive/2011/03/26/1996387.html

你可能感兴趣的:(js中array(数组)对象的splice方法的详解)