3 ms·
I don't understand why someone would use an ES6 feature like arrow funcs, but still use `var`
by spraak 10y ago
I don't understand why someone would use an ES6 feature like arrow funcs, but still use `var`
- inimino 10y agoBecause nothing is wrong with `var` and arrow functions are more concise?
- TheDong 10y ago> nothing is wrong with var Other than having utterly illogical scoping. Which is the entire reason 'let' was introduced and should always be preferred.
- inimino 10y agoPlease. 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.