Last active
December 21, 2015 09:29
-
-
Save torsday/6285408 to your computer and use it in GitHub Desktop.
Implemented 'last' functionality to an array in js #js #snippets
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
| // returns a single element of an array based upon it's offset from the end | |
| if (!Array.prototype.last){ | |
| Array.prototype.last = function(offset){ | |
| return this[this.length - offset]; | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment