1. Home
  2. Javascript
  3. Last n items

Select last n items from array

#javascript#array
// Number of items to select
numberOfItems = 100;
// Create a new array with last N items
let selectedArray = originalArray.slice( Math.max( originalArray.length - numberOfItems, 1 ) );
copy
Full Javascript cheatsheet