js getting the first x of items form array code example Example: array index javascript show only first 2 elements array.slice(0, n);