1.splice()属于数组对象的方法,若对象使用splice则会报错:
{a:1}.splice
运行结果:Uncaught SyntaxError: Unexpected token .
2.splice会改变原数组(slice不会):
var arr = [0,1,2,3];
arr.splice(2,1);
console.log(arr)
运行结果:[0, 1, 3]
3.当只插入元素时,是从索引的左边插入:
var arr = [0,1,2,3];
arr.splice(2,0,"b");
console.log(arr);
运行结果: [0, 1, "b", 2, 3]