global variable in JavaScript

The proper way is to use window object. And use the syntax like this:
```
var window.iAmGlobal = "some val"; //Global variable declaration with window.
 
function doSomething(){
    alert(window.iAmGlobal); //I am accessible here too !!
    alert(iAmGlobal); //I am accessible here too !!
}
```
By defining globals this way, you will make JavaScript more robust and reliable.
Important points:
* Define global variables with window keyword in form of “window.VAR_NAME”
* You can access the variable with “window.VAR_NAME” or directly “VAR_NAME”
* Do not use other variables with same name otherwise it may cause unwanted results