移除数组中元素

移除数组 arr 中的所有值与 item 相等的元素,直接在给定的 arr 数组上进行操作,并将结果返回

function removeWithoutCopy(arr, item) {
    return arr.filter(function(ele){
        return arr.splice(ele, item)
    })
}

 

posted @ 2018-05-03 15:41  拯救不开心  阅读(87)  评论(0)    收藏  举报