Skip to content

Instantly share code, notes, and snippets.

@geoffb
Created February 13, 2010 00:08
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 geoffb/303132 to your computer and use it in GitHub Desktop.
Save geoffb/303132 to your computer and use it in GitHub Desktop.
var myObject = function (someParam) {
var privateMember = "foobar";
return {
publicMethod: function () {
return "Hi! " + someParam + " " + privateMember;
}
};
};
var foo = new myObject("This is a test!");
console.log(foo.publicMethod()); // "Hi! This is a test! foobar"
console.log(foo.privateMember); // undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment