Skip to content

Instantly share code, notes, and snippets.

@tmpvar
Created May 14, 2010 06:10
Show Gist options
  • Save tmpvar/400866 to your computer and use it in GitHub Desktop.
Save tmpvar/400866 to your computer and use it in GitHub Desktop.
var bar = function() {
this._baz = function() {
return this.value;
};
};
bar.prototype = (function() {
var i_am_private = 2;
return {
i_am_public: 1,
get value() { return i_am_private + this.i_am_public; },
set value(val){ i_am_private = val; }
}
})();
//foo.i_am_public = 5;
//foo.value = 3;
//foo.value
//bar._baz = function() {
// return "the value is: " + this.value;
//};
//bar._baz();
var x = new bar();
//x.value
//x._baz = function() {
// return "the value is: " + this.value;
//};
//x._baz();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment