Skip to content

Instantly share code, notes, and snippets.

@tivac
Created September 11, 2009 21:50
Show Gist options
  • Save tivac/185610 to your computer and use it in GitHub Desktop.
Save tivac/185610 to your computer and use it in GitHub Desktop.
var Foo = (function () {
var prop;
function Foo(bar) {
this.prop = bar || "baz";
}
// private/protected functions here
function priv() {
return "Private: " + prop;
}
function pub() {
return "Public: " + priv();
}
Foo.prototype = {
pub : pub
};
return Foo;
})();
var f = new Foo("bar");
console.log(f.pub());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment