There is my attempt to recover the damage by balancing it with some benefits.
par1, par2, - Using parameters is out of scope of this article, just a note on the good habit to keep them read-only.
var1, var2, var3 - the local variables which are usually declared with var:
The good thing about such kind of declaration that along with declaring the variable it could be initialized.
IMO it is bad to have any uninitialized variable. Which means no ahead-declaration. The variable should be declared in place where it used and all initialization data are available:
But scripting guys do that all over thinking of saving bytes for "var " string and replacing with list of variables(as in #2, #4):
5 more bytes ('var ' and ';')could be taken away by having local variable declared as function parameters:
The list of useful side effect will appear:
- shrinking the code footprint
- no global scope variables mistakenly assigned(#6)
- questionable but will be loved by scripters(yuck) - declaring of
all variables in single comma-separated list.
To prevent potentially missing declaration variables usually used in local scope (i,j,o,r,d,x,y,z,k,w,n,m) could be listed in complex functions as the safeguard.
The compilers could do the optimization quite well. Not sure whether relocation of variable declaration into function parameters is an option there.