Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to push at top of array

const array = [3, 2, 1]

const newFirstElement = 4

const newArray = [newFirstElement].concat(array) // [ 4, 3, 2, 1 ]

console.log(newArray);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #push #top #array
ADD COMMENT
Topic
Name
9+4 =