4 ms·
I rarely use Javascript. When I do, I try to just not put anything in front of a variable I set, like in Python. I think this makes it global, but I'd rather
by ryan-duve 6y ago
I rarely use Javascript. When I do, I try to just not put anything in front of a variable I set, like in Python. I think this makes it global, but I'd rather remember that and deal with the consequences than remember the other rules. Of course, if I used it professionally or on a collaborative project I'd have to change that.
This articles makes me wonder why `var` is still a thing. Is it deprecated (or slated to be deprecated soon)? If not, why?
- ironmagma 6y agoYou can basically consider `var` to be deprecated. It's old and there's no reason to use it. That said, it will be supported forever because of the need to support old browsers and old websites. Modern JS codebases use a linter which will tell you not to use `var`. The rule is pretty simple: use `const` always, unless you can't because you are doing a reassign, in which case use `let`.