Created
February 23, 2015 22:52
-
-
Save hasinhayder/d41bda036b537a8728b8 to your computer and use it in GitHub Desktop.
Immutability via __defineGetter__
This file contains hidden or 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
var me = { | |
_first:"Count", | |
_last: "Dracula"; | |
} | |
me.__defineGetter__('first', function() { return this._first; }); | |
me.__defineGetter__('last', function() { return this._last; }); | |
me.first= "Die!"; | |
console.log(me.first); //still shows "Count" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bhaiya, but how come we still achieve this by doing nothing with defineSetter o.O
Github not letting me send pulls ....aaargh
https://gist.github.com/ahmedmohiduet/4f00a62eae6770c696e2