Created
March 8, 2011 23:46
-
-
Save xk/861387 to your computer and use it in GitHub Desktop.
selfShadowingGetter.js
This file contains 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
//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