📋 Table Of Content
index at which you want the item to be added.
To solve this we can go head with approaches using
splice() method overwrites the original array.
splice(start, deleteCount, item1)
start : The index at which the content will change
deleteCount: It mean the number of elements that will be removed from the start index. If it is 0 (zero) or negative, it means no elements will be removed.
item1 : The element that will be added in the array.
Lets check it with an example.
const months = ['Jan', 'March', 'April', 'June']; months.splice(1, 0, 'Feb'); console.log(months)
["Jan", "Feb", "March", "April", "June"]
Here we have added 'Feb' in index 1 in the array.
Note: In Array the