remove object from array javascript by id - How can I remove a specific item from an array?

remove element from array java / javascript / arrays

I have an array of numbers and I'm using the .push() method to add elements to it.

I'm looking for the equivalent of something like:



Answer #1

Remove ALL instances from an array

function array_remove_index_by_value(arr, item)
 for (var i = arr.length; i--;)
  if (arr[i] === item) {arr.splice(i, 1);}