Created
August 8, 2016 11:08
-
-
Save vitkon/40da1802b27c53c73410897354aeeafa to your computer and use it in GitHub Desktop.
last element in array
This file contains 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
const arr = [1, 2, 3, 4, 5]; | |
const last = [...arr].pop(); | |
// or | |
const [last2, ...rest] = arr.reverse(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment