Created
May 26, 2011 21:50
-
-
Save preslavrachev/994165 to your computer and use it in GitHub Desktop.
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
Clazz = function(num) { | |
var priv = num; | |
this.pub = priv; | |
that = this; | |
} | |
Clazz.prototype.outsider = function() { | |
return priv; | |
} | |
c = new Clazz(6); | |
c.priv; // not defined | |
c.pub; // 6 | |
c.outsider(); // not defined |
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
Clazz = function(num) { | |
priv = num; // removed the var from the definition | |
this.pub = priv; | |
that = this; | |
} | |
Clazz.prototype.outsider = function() { | |
return priv; | |
} | |
c = new Clazz(6); | |
c.priv; // not defined | |
c.pub; // 6 | |
c.outsider(); // 6!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment