Home > UI/UX Development > JavaScript > JavaScript: What is the difference between shift() and unshift() array methods?

JavaScript: What is the difference between shift() and unshift() array methods?

Definition:

shift(): this method is use to remove first element of an array and returns new array.

unshift(): this array method is used to add one or more arrays in existing array list and returns new array.

usages of shift():

usages of unshift():

 

This Article is TAGGED in , , , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">