Skip to content

Instantly share code, notes, and snippets.

@dakatsuka
Created October 3, 2011 00:32
Show Gist options
  • Save dakatsuka/1258174 to your computer and use it in GitHub Desktop.
Save dakatsuka/1258174 to your computer and use it in GitHub Desktop.
Array.prototype.__defineGetter__('first', function() {
return this[0];
});
Array.prototype.__defineGetter__('last', function() {
return this[this.length - 1];
});
Array.prototype.__defineSetter__('first', function(val) {
this[0] = val;
});
Array.prototype.__defineSetter__('last', function(val) {
if (this.length) {
this[this.length - 1] = val;
} else {
this[0] = val;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment