splice array of objects javascript code example
Example 1: remove element from array javascript
let fruit = ['apple', 'banana', 'orange', 'lettuce'];
fruit.splice(3, 1);
Example 2: remove object from array javascript
someArray.splice(x, 1);
Example 3: splice from array javascript to remove
let myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon']
let removed = myFish.splice(3, 1)
Example 4: 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);