How to remove all the elements from array
This question already has an answer here:
a.length = 0;
这就是你所需要的
var a = [2,3,4,5,6];
console.log(a);
a.length = 0;
console.log(a); Do a.length = 0; if you don't want to lose references. Do a = []; if you want to lose references.
上一篇: 如何清空数组
下一篇: 如何从数组中删除所有元素
