Just came across this question where someone passed
window.Module = window.Module || {}
into a function.
Here's an example:
(function(module){
// do something with module
})(window.Module = window.Module || {});
I get that if window.Module
is not defined (or false), then {}
will be passed in. But why set window.Module
equal to itself?
For those providing answers:
This is how I interpret the code:
if(!(window.Module = window.Module)) {
// pass {} into the function
}
else {
// pass window.Module = window.Module into the function
// (which doesn't make sense to me)
}