1. 程式人生 > >移除數組中元素

移除數組中元素

元素 bsp 數組 without ice item pre copy RR

移除數組 arr 中的所有值與 item 相等的元素,直接在給定的 arr 數組上進行操作,並將結果返回

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

移除數組中元素