The slice method is what you want. It returns a new object, so you must replace the existing object with a new one.
arr = arr.slice(-1 * n);
Alternatively, modify the existing array with splice() .
arr.splice(0, arr.length - n);
Splice is more efficient since it does not copy elements.
Craig source share