JavaScript Push em índice específico
arr.splice(index, 0, item);
//explanation:
inserts "item" at the specified "index",
deleting 0 other items before it
Dark Dotterel
arr.splice(index, 0, item);
//explanation:
inserts "item" at the specified "index",
deleting 0 other items before it
var colors=["red","blue"];
var index=1;
//insert "white" at index 1
colors.splice(index, 0, "white"); //colors = ["red", "white", "blue"]
arr.splice(index, 0, item);
// will insert item into arr at the specified index
// (deleting 0 items first, that is, it's just an insert).