Skip to content

Instantly share code, notes, and snippets.

@bantya
Last active August 13, 2016 17:59
Show Gist options
  • Save bantya/c49a8cdc8b8c749c2a8e65ea0c01a2ef to your computer and use it in GitHub Desktop.
Save bantya/c49a8cdc8b8c749c2a8e65ea0c01a2ef to your computer and use it in GitHub Desktop.
Extending Array with a Getter
var X = function () {
var self = this;
Object.defineProperty(self, 'abc', {get: function () { return 1; }});
};
// Extending & closing the loop
X.prototype = Array.prototype;
X.prototype.constructor = X;
// Works as you'd expect
console.log(new X().abc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment