モジュールパターンモジュールパターンとはシングルトンパターンの一種で、オブジェクトのプロパティをパブリック・プライベートにする。Douglas Crockford氏によって提唱されたらしい。 var module = function() {
var v1 = null;
var v2 = 10;
function init(v) {
v1 = v;
};
function func() {
return _func();
};
function _func() {
return v1 * v2;
};
function value() {
return v1;
}
return {
init : init,
func : func,
value : value
};
}();
参考
|
|