Troubleshooting JavaScript global variables
When working on large projects, not all developers use JSLint with strict settings. This can become a problem if a variable which is presumed to be local is actually global.
I wrote a test script, executable from a JavaScript Console such as FireBug, to echo the list of all global variables.
(function () {
var allAttrs = [], thisAttr;
for (thisAttr in window) {
allAttrs.push(thisAttr);
}
console.log(allAttrs);
})();
Advertisement
About this entry
You’re currently reading “Troubleshooting JavaScript global variables,” an entry on DJWortham
- Published:
- 2010/10/28 / 1:48 am
- Category:
- Web Development
- Tags:
- global variables, JavaScript, JSLint
No comments yet
Jump to comment form | comment rss [?] | trackback uri [?]