Obviously this is coded by script kid. In global execution context the
`this` value always refers to a global object. Using of `window` to
get global object here is useless and leads to confusion. If I have to
read that code, when I see formal parameter with name `global' I would
expect its value to be the value of `this` passed during invocation of
that function.
The whole idea for passing arguments to immediately executed function
expression leads readability problems. As a reader to see the actual
value of `global' I have to go to the end of the function. Usually
such functions are used for modules and therefore their body is longer
than my visible part of the monitor. I would have to scroll first to
the bottom and back again to the top.
The whole idea for that design comes from ECMAScript 5 strict-mode and
some premature lookup optimizations. In ECMAScript 5 if the function
code is strict code the `this` value is not coerced to global object,
on entering in the execution context of the function.
So this design is "defensive" and "performance" tuning. The programmer
expects some kid to put "use strict"; on the top of his code and that
would break the program. How this defense is reasonable is really
questionable. In the other hand during the debug stage strict-mode
would be helpful. Instead of passing arguments he can apply different
strategy. Using `call' method of fucntion he can explicitly provide
the value of `this` and therefore its value could be same in string
and non-strict mode.
(function () {
//...
}).call(this);
The `this` value is always bound to the `this` of surrounded execution
context. If the code is placed in global execution context the `this`
value in that function will always be a reference to global object.