Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Created September 3, 2016 19:39
Show Gist options
  • Save jasonbellamy/1a83ae3f53d65044db1d34f0bc548cc2 to your computer and use it in GitHub Desktop.
Save jasonbellamy/1a83ae3f53d65044db1d34f0bc548cc2 to your computer and use it in GitHub Desktop.
Get the value of the last item in an array using desctructing and the arrays .filter(), index, and length
const xs = [1, 2, 3, 4, 5];
const [ x ] = xs.filter((x, index, array) => {
return index === array.length);
}); // => 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment