js:将数组中不为0的值存入一个新的数组中var arr = [4,0,7,9,0,0,2,6,0,3,1]
var arr = [4,0,7,9,0,0,2,6,0,3,1]; var x; function zy(arr,x) { for(var i=0; i<arr.length;i++) { if(arr[i] == x) { arr.splice(i,1); i--; } } } zy(arr,0); console.log(arr);
赞 (0)
var arr = [4,0,7,9,0,0,2,6,0,3,1]; var x; function zy(arr,x) { for(var i=0; i<arr.length;i++) { if(arr[i] == x) { arr.splice(i,1); i--; } } } zy(arr,0); console.log(arr);