Home > UI/UX Development > JavaScript > JavaScript: What is the use of slice() array method?

JavaScript: What is the use of slice() array method?

This post was most recently updated on July 31st, 2024

Definition:
slice(): this array method is used to slice out specific portion of an array and returns new array. or We can use this method to get specific part and remove remaining part of an array. We can use two arguments in this method like slice(1,3).
When we use two arguments in this method, array selection starts from the first argument and up to the end argument but returns new array excluding end argument.

See the example code below:

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="">