Method 1 : Using unshift() method To add an element at the start of a JavaScript array, you can use the `unshift()` method. Here's an example:

const myArray = [2, 3, 4, 5];
myArray.unshift(1); // Add 1 at the start of the array
console.log(myArray); // Output: [1, 2, 3, 4, 5]

In this example, the `unshift()` method is called on the `myArray` array and passed the element `1` as an argument. This adds the element at the beginning of the array. The existing elements are shifted to the right, and the length of the array is increased by one. Method 2: Using concat() method Note that the `unshift()` method modifies the original array and returns the new length of the array. If you need a new array without modifying the original one, you can create a new array using the spread operator or the `concat()` method:

const myArray = [2, 3, 4, 5];
const newArray = [1, ...myArray]; // Using spread operator
console.log(newArray); // Output: [1, 2, 3, 4, 5]

// Alternatively, using concat()
const myArray = [2, 3, 4, 5];
const newArray = [1].concat(myArray);
console.log(newArray); // Output: [1, 2, 3, 4, 5]

Method 3 : Using splice() method


Let arr = [a,b, c]
arr.splice(0,0,x)
console.log(arr) //output - [x,a,b,c]

About splice() method : It takes 3 parameters : 1. The index from where to start 2. Number of elements to remove starting from that index 3. Comma seprated list of the elements to add