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 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: how to remove element from array in javascript
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");
colors.splice(carIndex, 1);
Example 4: delete from array javascript
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];var removed = arr.splice(2,2);
Example 5: remove from array javascript
let numbers = [1,2,3,4]
let last_num = numbers.pop();
let first_num = numbers.shift();
let number_index = 1
let index_num = numbers.splice(number_index,1);
Example 6: delete an item from array javascript
let items = [12, 548 ,'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' ,2154 , 119 ];
items.length;
items.splice(3,1) ;
items.length;