store.jsのソースコード、特にそれ自体がグローバルスコープにどのように追加されるかを調べていました:
if (typeof module != 'undefined') { module.exports = store }
else if (typeof define === 'function' && define.amd) { define(store) }
else { this.store = store }
最後のステートメントは理解できthis.store = store
ますが、他のステートメントはどうですか? module
およびdefine
関数とは何ですか? this.store = store
まだすべてのブラウザーで動作しませんか?
より一般的には、グローバル スコープにモジュールを追加するための正しいクロスブラウザーの方法は何ですか?