Skip to content

Instantly share code, notes, and snippets.

@xk
Created March 8, 2011 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xk/861387 to your computer and use it in GitHub Desktop.
Save xk/861387 to your computer and use it in GitHub Desktop.
selfShadowingGetter.js
//20110308 jorge@jorgechamorro.com
Object.defineProperty(thePrototype, 'parsedUrl', {
get: function () {
var parsed= url.parse(this.url, true);
this.__proto__= null; // cuts momentarily the proto chain
this.parsedUrl= parsed; // shadows the getter
this.__proto__= thePrototype; // restores the proto chain
return parsed;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment