delete 和 splice 删除数组中元素的区别
`
var arr1 = ["a","b","c","d"];
delete arr1[1];
console.log(arr1);//["a",undefined,"c","d"];
console.log(arr1.length);//4;
var arr2 = ["a","b","c","d"];
arr2.splice(1,1);
console.log(arr2);//["a","c","d"];
console.log(arr2.length);//3;
`
总结:
delete 和 splice 同样都能删除数组中的元素,delete删除把被删除的元素变成了undefined不会改变原数组的长度,splice则会改变原数组--直接删除,包括长度