Javascript Variable Scoping

March 12, 2017, 1:25 a.m.

Vanilla Javascript has only function scope and no block scope. Python is like this too, but Python at least doesn't try to mislead you into thinking you can shadow a local variable by redeclaring it inside a block. That's because Javascript variables, without the var "declaration", is implicitly global, whereas Python variables is by default local.

Javascript is pretty messed up. News at 11.

And then when you look up this issue, some people recommend moving all the var declarations to the top of the function. What is this, C89?