return 0 thru 4 elements javascript code example Example: array index javascript show only first 2 elements array.slice(0, n);