2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

what is the best way to declare a global variable in javascript

 what is the best way to declare a global variable in javascript
userimage
JavaScriptÂ’s flaws is that scripts on a page are all executed in a shared global context which leave a website vulnerable to cross-site scripting attacks. Those scripts run in the global space and can all access the same global variables. If two of those scripts happen to use the same global variable, they begin interfering with each other. The code then breaks.

var globVar = {};
globVar.id = 188;

So we can use above way to declare a global variable.
Answer is