Answers for "js insert item into array"

21

js insert item into array

var colors=["red","blue"];
var index=1;

//insert "white" at index 1
colors.splice(index, 0, "white");   //colors =  ["red", "white", "blue"]
Posted by: Guest on July-22-2019

Code answers related to "js insert item into array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language