Skip to content

Instantly share code, notes, and snippets.

@kaneshin
Created September 19, 2011 05:07
Show Gist options
  • Save kaneshin/1226002 to your computer and use it in GitHub Desktop.
Save kaneshin/1226002 to your computer and use it in GitHub Desktop.
function type constructor
var constructor = function(spec, my) {
var that = {},
/* private instance variables */
foo;
/* shared objects */
my = my || {};
/** accessible method */
that.hoge = function() {
huga();
alert(foo);
};
/** privileged method */
function huga() { // var huga = function() {
foo = spec.bar;
}
return that;
};
var myConstructor = constructor({ bar: "baz" });
myConstructor.hoge();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment