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

Is there a simple way to remove a specific element from an array? The equivalent of something like array.remove(int);.

I have to use core JavaScript - no frameworks are allowed.


closed as off-topic by Yuval Filmus, Apass.Jack, Gilles Jan 11 at 10:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development or programming tools are off-topic here, but can be asked on Stack Overflow." – Yuval Filmus, Apass.Jack
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ JavaScript questions are off-topic here but could be on-topic on stackoverflow. $\endgroup$ – Yuval Filmus Jan 11 at 8:25
  • $\begingroup$ I can remove all instances from an array using ::: function remove(arr, item) { for (var i = arr.length; i--;) { if (arr[i] === item) { arr.splice(i, 1); } } } $\endgroup$ – user98753 Jan 11 at 8:31
  • $\begingroup$ then how to do the above one ... $\endgroup$ – user98753 Jan 11 at 10:20
  • $\begingroup$ "JavaScript questions are off-topic here" was not an invitation to post more JavaScript questions. $\endgroup$ – David Richerby Jan 11 at 15:48