js数组删除所有重复的元素答:function delArrElem(arr, s){ var i=arr.length; while(i--)if(arr[i]===s)arr.splice(i,1); return arr;}var arr=[3,78,34,123,4,5,66,34,55];alert(arr);alert(delArrElem(arr,34));
js中怎么去掉数组的空值,不知道是第几个,只要是空值就删除答:不知道这个效果是否达到要求: var array = [1,2,,,4,6,,,55]; alert(array) for(var i = 0 ;i<array.length;i++) { if(array[i] == "" || typeof(array[i]) == "undefined") { array.splice(i,1); i= i-1; } } alert(array) ...
js 把二维数组中指定元素提出,与其余元素组成新的数组答:let list = [ { id: "247", order_number: "21251", name: "张三", tel: 13911111, color: "黑色", weight: "10kg" }, { id: "248", order_number: "21251", name: "张三", tel: 13911111, color: "白色", weight: "13kg" ...