Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the usage of unshift() method in javascript ?

user-image
Question added by doaa elsayed , معلم حاسب ألى , مدرسة الأنفوشى الرسمية (لغات)
Date Posted: 2017/04/20
medhatmahmoud mahmoud
by medhatmahmoud mahmoud , Web Designer , Connect Computer Service Co

Adds new elements to the beginning of an array, and returns the new length

vishnuvarthan v
by vishnuvarthan v , Associate programmer , logimax

Add new items to the beginning of an array

example

{

var fruits = ["Banana""Orange""Apple""Mango"];fruits.unshift("Lemon","Pineapple");

}

 

 

 

The unshift() method adds new items to the beginning of an array, and returns the new length.

This method changes the length of an array.

To add new items at the end of an array, use the push() method.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.