[javascript] How to get first N number of elements from an array

To get the first n elements of an array, use

array.slice(0, n);