Created
March 24, 2021 23:12
-
-
Save Atlas48/5ed286157324e964fae92a65038ef18b to your computer and use it in GitHub Desktop.
Adds access to first and last elements of an 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
Object.defineProperty(Array.prototype, 'last', {get:function(){return this[this.length-1];}}) | |
Object.defineProperty(Array.prototype, 'first', {get:function(){return this[0];}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment