I was having a look at the source code of store.js, in particular how it adds itself to the global scope:
if (typeof module != 'undefined') { module.exports = store }
else if (typeof define === 'function' && define.amd) { define(store) }
else { this.store = store }
I understand the last statement this.store = store
, but how about the other ones? What are the module
and define
functions? Won't this.store = store
already work on all the browsers?
More generally, what is the correct, cross-browser way, to add a module to the global scope?