var arr = ["X1", "X2", "X3", "X4", "X5"];
Inserting "X2.2" into position "2" without deleting "0" item
arr.splice(2, 0, "X2.2");
First Array Values:
X1, X2, X3, X4, X5
After insert new value:
X1, X2, X2.2, X3, X4, X5
Showing posts with label splice. Show all posts
Showing posts with label splice. Show all posts
Friday, December 30, 2016
How to insert an item into an array at a specific index javascript
Subscribe to:
Posts (Atom)