私は次のコードを持っています。これはJavaScriptモジュールです。
(function() {
// Object
var Cahootsy;
Cahootsy = {
hello: function () {
alert('test');
},
};
(Cahootsy.scope = (function() {
return this;
})()).Cahootsy = Cahootsy;
return Cahootsy;
}).call(this);
セクションがわかりません:
(Cahootsy.scope = (function() {
return this;
})()).Cahootsy = Cahootsy;
'this'モジュールを参照するオブジェクトを作成してから、Cahootsy変数をグローバルCahootsy変数に割り当てていると思います。私が理解していないのは、なぜ「これ」をCahootsy.scopeに割り当てる必要があるのかということです。