Answers for "javascript insert item at beginning of array"

56

javascript add new array element to start of array

var colors = ["white","blue"];
colors.unshift("red"); //add red to beginning of colors
// colors = ["red","white","blue"]
Posted by: Guest on July-23-2019
1

insert data at first position in array javascript

const fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.unshift("Lemon","Pineapple");
Posted by: Guest on July-24-2021
10

unshift method in javascript

var name = [ "john" ];
name.unshift( "charlie" );
name.unshift( "joseph", "Jane" );
console.log(name);

//Output will be
[" joseph "," Jane ", " charlie ", " john "]
Posted by: Guest on August-02-2020

Code answers related to "javascript insert item at beginning of array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language