first N elements of an array javascript code example Example: first N elements of an array javascript const slicedArray = array.slice(0, n);