3 ms·
Please. There's nothing illogical about it. It scopes to the function body. Maybe you meant to write "unfamiliar".
by inimino 10y ago
Please. There's nothing illogical about it. It scopes to the function body. Maybe you meant to write "unfamiliar".
- nv-vn 10y agoIt's entirely unintuitive, inconsistent with the syntax, and is generally senseless. "var" lacks an easy to explain meaning because in many cases it doesn't even introduce a variable.
- inimino 10y agoIt ensures that a variable is declared in the current scope. That's the easy to explain meaning. It's inconsistent with other languages which introduce a new scope whenever there are curly braces, but there's nothing inconsistent about the syntax. That's just a matter of taking expectations from other languages and expecting them to work unchanged in JavaScript.