array method to remove an element code example
Example 1: remove a particular element from array
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");
colors.splice(carIndex, 1);
Example 2: remove element from array in js
var myArray = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
myArray.splice(0,2)
let itemToBeRemoved = ["Sunday", "Monday"]
var filteredArray = myArray.filter(item => !itemToBeRemoved.includes(item))
Example 3: javascript remove element from array
const cars = ['farrari', 'Ice Cream', 'tata', 'BMW']
cars.splice(colors.indexOf('Ice Cream'), 1);
cars.pop();