how to remove array index 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: array remove index from array
const array = [2, 5, 9];
const index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
console.log(array);
Example 3: javascript remove index from array
array.splice(index, 1);
Example 4: js delete all from array
var list = [1, 2, 3, 4];
function empty() {
list.length = 0;
}
empty();