Skip to content

Instantly share code, notes, and snippets.

@jakelodwick
Created August 17, 2014 19:02
Show Gist options
  • Save jakelodwick/0ed95c271587870feb5b to your computer and use it in GitHub Desktop.
Save jakelodwick/0ed95c271587870feb5b to your computer and use it in GitHub Desktop.
Get last element of array
# last element of array,
# alternative to `my_array[my_array.length - 1]`
# via http://stackoverflow.com/questions/9050345/selecting-last-element-in-javascript-array
unless Array::last
Array::last = ->
this[@length - 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment