Skip to content

Instantly share code, notes, and snippets.

@Atlas48
Created March 24, 2021 23:12
Show Gist options
  • Save Atlas48/5ed286157324e964fae92a65038ef18b to your computer and use it in GitHub Desktop.
Save Atlas48/5ed286157324e964fae92a65038ef18b to your computer and use it in GitHub Desktop.
Adds access to first and last elements of an array.
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