Created
September 19, 2011 05:07
-
-
Save kaneshin/1226002 to your computer and use it in GitHub Desktop.
function type constructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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