delete element in array at index js code example
Example 1: javascript remove from array by index
array.splice(index, 1);
Example 2: remove item from array javascript
const array = [2, 5, 9];
console.log(array);
const index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
console.log(array);
Example 3: remove in javascript
function arrayRemove(arr, value)
{
return arr.filter(function(ele){
return ele != value;
});
}
Example 4: how to delete an element from an array in javascript
["bar", "baz", "foo", "qux"]list.splice(0, 2)