我有这个功能:
(function(window, document,undefined) {
'use strict';
function Test() {
this.init = function() {
console.log("init");
}
};
return new Test;
})(window, document);
我知道class Test
只有在这种情况下才能访问。但我想这样做:
Test.init();
如果我将它存储到一个变量中并这样做:
var t = (function() {...})();
并且这样做console.log(t)
会返回class itself
然后,我可以检索它。但我不想这样做
我想知道,有没有办法从这个 Javascript 自调用函数中检索这个类?如果可能的话,如何实现它?
这是我正在使用的小提琴:http: //jsfiddle.net/grnagwg8/
问候,