Created
July 1, 2014 14:39
-
-
Save DerZyklop/8165871c4db25b762c34 to your computer and use it in GitHub Desktop.
How to get the last item of an javascript array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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