how to insert element in array in js code example
Example 1: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array); //output will be =>
["John", "Sally", "Mike"]
Example 2: insert item into array specific index javascript
myArray.splice(index, 0, item);
Example 3: array insertion javascript
Array.prototype.insert = function ( index, item ) {
this.splice( index, 0, item );
};