Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Created February 23, 2015 22:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hasinhayder/d41bda036b537a8728b8 to your computer and use it in GitHub Desktop.
Save hasinhayder/d41bda036b537a8728b8 to your computer and use it in GitHub Desktop.
Immutability via __defineGetter__
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"
@ahmedmohiduet
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment