Add Element to the Start of an Array in JavaScript

This is a preview lesson
Register or sign in to take this lesson.

This tutorial shows how to add element to the start of an array. In JavaScript, we can achieve this by using unshift() method.

Example

const array = [1,2,3,4,5];

array.unshift(12);

console.log("Final array is: ", array)
Output
Final array is: [ 12, 1, 2, 3, 4, 5 ]