This may be a silly question, but why are function arguments in JavaScript not preceded by the var keyword?
Why:
function fooAnything(anything) {
r
I think the question comes up because we're used to seeing function bla (int i)
in many languages. The same, syntactically, as the int i;
somewhere in the function body to declare a variable. The two int
s are however not doing the same; the first defines the type, the second defines type and the scope. If you don't have to declare the type, the scope-declaration still needs to happen (which is why we have var
in the second case) but there is no information needed in front of arguments.