delete a element from array javascript code example
Example 1: javascript remove from array by index
array.splice(index, 1);
Example 2: remove array elements javascript
let value = 3
let arr = [1, 2, 3, 4, 5, 3]
arr = arr.filter(item => item !== value)
console.log(arr)
Example 3: js remove element from array
const array = [2, 5, 9];
console.log(array);
const index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
console.log(array);
Example 4: javascript array remove
let yourArray = ["aaa", "bbb", "ccc", "ddd"];
yourArray.pop();
let yourArray = ["aaa", "bbb", "ccc", "ddd"];
yourArray.shift();