Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How can I add new array elements at the beginning of an array in JavaScript?

var arr = [23, 45, 12, 67];
arr = [34, ...arr]; // RESULT : [34,23, 45, 12, 67]

console.log(arr)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #I #add #array #elements #beginning #array
ADD COMMENT
Topic
Name
2+1 =