3 ms·
Well no, if you can't declare any variable without 'var', the ' dir= "data" ' line is very explicitly assignment and not a variable declaration. You can still m
by Raphael_Amiard 16y ago
Well no, if you can't declare any variable without 'var', the ' dir= "data" ' line is very explicitly assignment and not a variable declaration. You can still make the mistake but the piece of code would stand out.
The problem in javascript is that "a=12" does create a new variable, even if it's a global, and that many people just go through their code declaring only globals.
If you did get a syntax error everytime you did that, you'd soon have the habit of putting var in front of every new variable you declare.
- AndyKelley 16y agoThat's true. All things considered, I think I'd rather have the "var" implementation, crash when using an undeclared variable, and even with the ability to clobber globals if you forget to use "var".