How to get first N number of elements from an array

To get the first n elements of an array, use

const slicedArray = array.slice(0, n);

Leave a Comment