Answers for "javascript insert item into array"

21

javascript 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
8

js add item to array

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Posted by: Guest on June-10-2020

Code answers related to "javascript insert item into array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language