slice array from N to last element

Don't use the second argument:

Array.slice(2);

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice

If end is omitted, slice extracts to the end of the sequence.


An important consideration relating to the answer by @insomniac is that splice and slice are two completely different functions, with the main difference being:

  • splice manipulates the original array.
  • slice returns a sub-set of the original array, with the original array remaining untouched.

See: http://ariya.ofilabs.com/2014/02/javascript-array-slice-vs-splice.html for more information.

Tags:

Javascript