delete
delete将删除对象属性,但不会重新索引数组或更新其长度。...这使它看起来好像是未定义的:
> myArray = ['a', 'b', 'c', 'd']
["a", "b", "c", "d"]
> delete myArray[0]
true
> myArray...[0]
undefined
请注意,它实际上未设置为undefined值,而是从数组中删除该属性,使其显示为undefined。...myArray[0]
undefined
> myArray
[empty, "b", "c", "d"]
splice
myArray.splice(start, deleteCount)实际上删除元素...,重新索引数组,并更改其长度。