4 ms·
It'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 eve
by nv-vn 10y ago
It'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.