how to select element from array in javascript by index code example Example: array index javascript show only first 2 elements array.slice(0, n);