javascript splice return remaining items code example
Example 1: splice method js
let myFish = ['angel', 'clown', 'mandarin', 'sturgeon']
//insert new element into array at index 2
let removed = myFish.splice(2, 0, 'drum')
// myFish is ["angel", "clown", "drum", "mandarin", "sturgeon"]
// removed is [], no elements removed
Example 2: Array#splice
let arrDeletedItems = array.splice(start[, deleteCount[, item1[, item2[, ...]]]])