Skip to content

Instantly share code, notes, and snippets.

@tkiley
Created March 11, 2011 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkiley/866103 to your computer and use it in GitHub Desktop.
Save tkiley/866103 to your computer and use it in GitHub Desktop.
function Foo() {
var my_private;
this.get_my_private = function() { return my_private; }
this.set_my_private = function(newval) { my_private = newval; }
}
x = new Foo();
x.set_my_private("this is a test private value");
x.get_my_private();
x.my_private; // this is undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment