splice in mdn code example
Example 1: javascript splice
let arr = ['foo', 'bar', 10, 'qux'];
arr.splice(1, 1);
arr.splice(2, 1, 'tmp');
arr.splice(0, 1, 'x', 'y');
Example 2: array.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 typescript array
var arr = ["orange", "mango", "banana", "sugar", "tea"];
var removed = arr.splice(2, 0, "water");
console.log("After adding 1: " + arr );
console.log("removed is: " + removed);
removed = arr.splice(3, 1);
console.log("After removing 1: " + arr );
console.log("removed is: " + removed);
Example 4: splice from array
let myFish = ['angel', 'clown', 'mandarin', 'sturgeon']
let removed = myFish.splice(2, 0, 'drum')