splice element array javascript code example
Example 1: javascript remove element from array
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]
Example 2: splice from array javascript to remove
let myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon']
let removed = myFish.splice(3, 1)
// myFish is ["angel", "clown", "drum", "sturgeon"]
// removed is ["mandarin"]