javascript 清空数组的方法
1,splice
var ary = [1,2,3,4]; ary.splice(0,ary.length); console.log(ary); // 输出 [],空数组,即被清空了
2,length赋值为0
var ary = [1,2,3,4]; ary.length = 0; console.log(ary); // 输出 [],空数组,即被清空了
3,赋值为[]
var ary = [1,2,3,4]; ary = []; // 赋值为一个空数组以达到清空原数组