‘var’ statement compulsory in JavaScript on IE

Web Development No Comments »

In theory you should be able to omit the ‘var’ statement when declaring a variable. Most people use it, but it isn’t required.

In IE, however, leaving ‘var’ out has a side effect – if you use the variable name as an element id in your html, you are likely to get some vague errors form IE.

I recently spent some time trying to figure out why a very simple bit of test code was not working in IE, but worked fine in other (better?) browsers.

 
Powered by WordPress, Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in