Answers for "how to push item at the beginning of array js"

56

javascript push item to beginning 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

Add an item to the beginning of an Array

let newLength = fruits.unshift('Strawberry') // add to the front
// ["Strawberry", "Banana"]
Posted by: Guest on July-02-2021

Code answers related to "how to push item at the beginning of array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language