splice javascript example
Example 1: splice javascritp
let colors = ['red', 'blue', 'green'];
let index_element_to_be_delete = colors.indexOf('green');
colors.splice(index_element_to_be_delete);
//Colors now: ['red', 'blue']
Example 2: splice from array
let myFish = ['angel', 'clown', 'mandarin', 'sturgeon']
let removed = myFish.splice(2, 0, 'drum')
// myFish is ["angel", "clown", "drum", "mandarin", "sturgeon"]
// removed is [], no elements removed