Way One:数组方法之forEach
function remove(arr, item) {
let newArr=[];
arr.forEach(it=>{
if(it!==item) newArr.push(it);
});
return newArr;
}
Way Two:数组方法之filter()
经亲测,filter里面貌似不能用箭头函数。
function remove(arr, item) {
return arr.filter(function(ele){
return ele!==item;
});
}