how to select a specific number of elements from an array in js code example Example: array index javascript show only first 2 elements array.slice(0, n);