Skip to content

Instantly share code, notes, and snippets.

@preslavrachev
Created May 26, 2011 21:50
Show Gist options
  • Save preslavrachev/994165 to your computer and use it in GitHub Desktop.
Save preslavrachev/994165 to your computer and use it in GitHub Desktop.
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
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