Using Array#slice to get a subset of the array

Sometimes, we want a subset of an array based on the array indices rather than on the contents of the array at those indices. In this recipe, we'll take a look at how to use slice to get a subset of an array.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.