how does splice work code example
Example 1: splice javascript
let arr = ['foo', 'bar', 10, 'qux'];
arr.splice(1, 1);
arr.splice(2, 1, 'tmp');
arr.splice(0, 1, 'x', 'y');
Example 2: splice javascript
const numbers = [10, 11, 12, 12, 15];
const startIndex = 3;
const amountToDelete = 1;
numbers.splice(startIndex, amountToDelete, 13, 14);
console.log(numbers);
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: splice from array
let myFish = ['angel', 'clown', 'mandarin', 'sturgeon']
let removed = myFish.splice(2, 0, 'drum')