JavaScript Objects The Array Object- unshift() - Javascript Objects

What is JavaScript - Array unshift() Method?

Javascript array unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.


Its syntax is as follows −

Parameter Details

element1, ..., elementN − The elements to add to the front of the array.

Return Value

Returns the length of the new array. It returns undefined in IE browser.


Try the following example.


Returned array is : water,orange,mango,banana,sugar

Length of the array is : 5

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Javascript Objects Topics