array remove elements 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: js remove item array
let originalArray = [1, 2, 3, 4, 5];
let filteredArray = originalArray.filter((value, index) => index !== 2);
Example 3: javascript remove element from array
const cars = ['farrari', 'Ice Cream', 'tata', 'BMW']
cars.splice(colors.indexOf('Ice Cream'), 1);
cars.pop();
Example 4: remove in javascript
function arrayRemove(arr, value)
{
return arr.filter(function(ele){
return ele != value;
});
}
Example 5: how to delete an element from an array in javascript
["bar", "baz", "foo", "qux"]list.splice(0, 2)