splice 增,删,改
/*shift pop*/
var arr = [4,5,6,7,8]
/*
splice(index,howmany)
index--从那个下标开始删除
howmany删除几个
*/
arr.splice(2,2)
console.log(arr)
/*
修改 "vue"
splice(index,howmany,value)
index 下标
howmany 删除多少个
value 替代的值
*/
var arr = ["html","css","javascript"];
arr.splice(1,1,"vue")
console.log(arr)
/*splice 增加
从下标的前面添加
splice(index,0,value...)
*/
var arr = [3,4,5,6]
arr.splice(2,0,"html","css");
console.log(arr)
/*增,删,改,*/
var arr = [3,4,5,6];
/*
[3,4,"html",5,6]
splice(index,0,value)
*/
arr.splice(2,0,"html");
console.log(arr)
/*
删除
splice(index,howmany)
*/
var test = [1,2,3,4,5]
//[1,4,5]
test.splice(1,2);
console.log(test)
var arr = [2,3,4,5]
//[2,3,"vue",5]
//arr.splice(index,howmany...value)
arr.splice(2,1,"vue")
console.log(arr)