In javascript if I have to use a variable foo then I have to first define it as var foo. But when we use parameters in functions, e.g. as:
function myfunc(bar) {
alert(bar);
}
why don't we write function myfunc(var bar) {...} instead? How does javascript know that bar is a variable? I remember that in C++ we have to tell that the compiler that the parameter being passed to the function is a variable as
int myfunc ( char bar[] ) {...}
baris a parameter because that's the only thing it can be.