Question:

Which array method in JavaScript is used to insert an element at the beginning of an array ?

Show Hint

To remember this: push/pop work on the end of the array, whereas unshift/shift work on the beginning of the array. The longer word in each pair adds elements (push, unshift), while the shorter word removes elements (pop, shift).
Updated On: Jun 29, 2026
  • push()
  • unshift()
  • concat()
  • pop()
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation



Step 1: Reviewing Common JavaScript Array Methods:

JavaScript provides standard methods on the Array.prototype to manipulate elements at different ends of an array. Let's analyze their operations:

Step 2: Evaluating the Options:


(A) push(): Adds one or more elements to the end of an array and returns the new length of the array.
(B) unshift(): Adds one or more elements to the beginning of an array and returns the new length of the array.
(C) concat(): Is used to merge two or more arrays. This method does not mutate the existing arrays, but instead returns a brand-new array.
(D) pop(): Removes the last element from an array and returns that element. Therefore, unshift() is the correct choice to insert at the beginning.
Was this answer helpful?
0
0