SOURCE

let a=['a','b','c','d']
a.splice(2, 1)
console.log('js删除数组中已知下标的元素')
console.log(a)
console.log('')
//补充:

//splice增加:
let b=['a','b','c','d']
b.splice(1,0,'abc')
console.log('splice替换1')
console.log(b)
console.log('')

//splice替换1:
let c=['0','1','2','3']
c.splice(1,1,'abc')
console.log('splice增加')
console.log(c)
console.log('')

//splice替换2:(就是说:下标1开始2个换成1个“abc”)
let d=['00','01','02','03']
d.splice(1,2,'abc')
console.log('splice替换2')
console.log(d)
console.log('')

//splice删除多个:
let e=['a1','a2','a3','a4']
e.splice(1,2)
console.log('splice删除多个')
console.log(e)
console.log('')

//delete:删除后,该下标位置元素为undefined或null
let f= ['a01','a02','a03','a04']
delete f[0];
console.log('delete:删除后')
console.log(f)
console 命令行工具 X clear

                    
>
console