JavaScript – Remove particular element from an array

To remove particular element from an array, you can make use of filter() method in JavaScript. Let’s see how we can use filter to remove any particular element.

// Given an array
let arr = [1, 2, 3, 4, 5];

// Remove the element '3' from the array
let newArr = arr.filter(function(value) {
  return value !== 3;
});

console.log(newArr); // Output: [1, 2, 4, 5]

Similar Reads