1let myFish = ['angel', 'clown', 'mandarin', 'sturgeon']
2//insert new element into array at index 2
3let removed = myFish.splice(2, 0, 'drum')
4
5// myFish is ["angel", "clown", "drum", "mandarin", "sturgeon"]
6// removed is [], no elements removed
1Check Out my CODE-PEN for this Solution
2
3https://codepen.io/siddhyaOP/pen/eYgRGOe
4https://codepen.io/siddhyaOP/pen/eYgRGOe
5https://codepen.io/siddhyaOP/pen/eYgRGOe
1const numbers = [2, 4, 5, 3, 8, 9, 11, 33, 44];
2const spliceNumbers = numbers.splice(0, 5)
3//start from 0 && remove next 5 elements
4console.log(spliceNumbers)
5//Expected output:[ 2, 4, 5, 3, 8 ]
1Splice and Slice both are Javascript Array functions. Splice vs Slice. The splice() method returns the removed item(s) in an array and slice() method returns the selected element(s) in an array, as a new array object. The splice() method changes the original array and slice() method doesn't change the original array.27-Jan-2018
1// elem törlése
2let myArray = ['a', 'b', 'c', 'd']
3// 0. indextől számolva 2 elemet távolít el
4myArray.splice(0, 2)
5console.log(myArray)
6// --> [ 'c', 'd' ]
7
8// beszúrás
9const months = ['Jan', 'March', 'April', 'June'];
10// az 1-es indexű helyre illeszt be:
11months.splice(1, 0, 'Feb');
12console.log(months);
13// --> ['Jan', 'Feb', 'March', 'April', 'June']
1let arrDeletedItems = array.splice(start[, deleteCount[, item1[, item2[, ...]]]])
2