Last active
December 21, 2015 07:49
-
-
Save vipickering/6274128 to your computer and use it in GitHub Desktop.
Javascript: Find 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
if (!Array.prototype.last){ | |
Array.prototype.last = function(){ | |
return this[this.length - 1]; | |
}; | |
}; | |
//invoke via: array.last(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment