Getting a reference to the global object in an unknown environment in strict mode

In ES5, you can get a reference to global object from within strict mode via indirect eval call:

"use strict";
var global = (1,eval)('this');

Take a look at my article; particularly at this section on strict mode.


In global code, the thisBinding is set to the global object regardless of strict mode. That means you can pass it from there into your module IEFE:

// "use strict"; or not
(function(global) {
    "use strict";
    …
    console.log(global);
    …
}(this));