JS array delete splice 区别

Delete in this case will only set the element as undefined:

> myArray =['a','b','c','d']

>delete myArray[0]

true

> myArray

[undefined,"b","c","d"]

Splice actually removes the element from the array:

> myArray =['a','b','c','d']

>myArray.s
plice(0,1)
true

> myArray

["b","c","d"]
 
posted @ 2014-06-10 11:22  乡村猫  阅读(561)  评论(0编辑  收藏  举报