Skip to content

Instantly share code, notes, and snippets.

@fxp
Created September 13, 2018 13:21
Show Gist options
  • Save fxp/30ee955296848f0de4f913a81c96edba to your computer and use it in GitHub Desktop.
Save fxp/30ee955296848f0de4f913a81c96edba to your computer and use it in GitHub Desktop.
Select the last element of a array
var arr = [1,2,3,4];
var last = arr.slice(-1)[0];
console.log(last);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment