1、splice函数
let a = [1,2]
a.splice(0,a.length)
console.log(a);//[]
2、赋予空值
let a = [1,2]
a = []
console.log(a)//[]
3、给数组的length赋值为0
let a = [1,2]
a.length = 0
console.log(a)//[]
2024-03-14 14:24:28
let a = [1,2]
a.splice(0,a.length)
console.log(a);//[]
let a = [1,2]
a = []
console.log(a)//[]
let a = [1,2]
a.length = 0
console.log(a)//[]
下一篇:js前端-》删除数组中的对象