If you have ever written JavaScript for a web page, one of the first things that you learned may have been that the window object is basically a reference to the global scope. On the other hand, if you have ever programmed in JScript (Windows Scripting Host), you will know that the window object doesn’t exist. Personally, I don’t know of a reference to the global scope object in JScript. Therefore, if you need one, you can use the following code:

var global = (function(){ return this; })();  // global scope object
Categories: BlogJScript

Leave a Reply

Your email address will not be published. Required fields are marked *