how to return partial array in array of object in js code example Example: array index javascript show only first 2 elements array.slice(0, n);