Learn how to insert an element in specified index of the array in Javascript.
The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in-place(in original array).

The splice method will take three argument β startΒ , deleteCount(optional), items to add (optional)Β .
In the above program we are deleting 0 elements from index 2 and adding 3 into 2 index.
We can also add multiple elements into itΒ .
var array = [1,2,4,5];
array.splice(2, 0, 3, 4, 3, 4); // [1,2,3,4,3,4,4,5]
If you find this helpful surprise π me here.
Share if you feel happy π π πΒ .
Follow Javascript Jeepπ if you feel worthy.