How to get the global object in JavaScript?
Well, you can use the typeof operator, and if the identifier doesn’t exist in any place of the scope chain, it will not throw a ReferenceError, it will just return “undefined”: if (typeof ModuleName != ‘undefined’) { //… } Remember also that the this value on Global code, refers to the global object, meaning that … Read more