Created
September 13, 2018 13:21
-
-
Save fxp/30ee955296848f0de4f913a81c96edba to your computer and use it in GitHub Desktop.
Select the last element of a 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
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