Skip to content

Instantly share code, notes, and snippets.

@DerZyklop
Created July 1, 2014 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerZyklop/8165871c4db25b762c34 to your computer and use it in GitHub Desktop.
Save DerZyklop/8165871c4db25b762c34 to your computer and use it in GitHub Desktop.
How to get the last item of an javascript array
array = [
{
position: 'first'
mood: 'meh...'
}
{
position: 'second'
mood: 'Yuck!'
}
{
position: 'last'
mood: 'Hooray!!'
}
]
console.log array[array.length - 1].mood
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment