splice in javascript array code 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);
Example 2: splice javascript
const months = ['Jan', 'March', 'April', 'June'];
months.splice(1, 0, 'Feb');
console.log(months);
months.splice(4, 1, 'May');
console.log(months);
months.splice(0, 1);
console.log(months);
Example 3: splice method js
let myFish = ['angel', 'clown', 'mandarin', 'sturgeon']
let removed = myFish.splice(2, 0, 'drum')
Example 4: splice javascript
let arrDeletedItems = arr.splice(start[, deleteCount[, item1[, item2[, ...]]]])
Example 5: what is splice method in javascript
Check Out my CODE-PEN for this Solution
https://codepen.io/siddhyaOP/pen/eYgRGOe
https://codepen.io/siddhyaOP/pen/eYgRGOe
https://codepen.io/siddhyaOP/pen/eYgRGOe