entropia
10/4/2017 - 12:00 PM

Remove element from Array

// example array
var arr = [1,2,3,4]
// Without touching prototype
function remove(arr, val) {
    return arr.filter(function(e) { return e !== val })
}
//call like
remove(arr, 5)

//With prototype
Array.prototype.remove = function (val) {
    return this.filter(function(e) {return e !== val})
}
// call like
arr.remove(1)