Why don't you replace `var` with `const` and `let`?
See original GitHub issueSummary
It seems that there are many var
in the source code.
And using const
and let
instead is more preferred.
So, why don’t you replace var
with const
and let
?
Tell me the reason that you make var
be left?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Var, Let, and Const – What's the Difference? - freeCodeCamp
var declarations are globally scoped or function scoped while let and const are block scoped. var variables can be updated and re-declared ......
Read more >Replacing let with const - Charles Stover - Medium
It's common practice to use const by default, denoting that a variable is constant and unchanging. However, it can be confusing when you...
Read more >Five things to know about var, let, and const in JavaScript
1. They are all used to create bindings ; var : Short for “variable.” This is the old-fashioned way we used in pre-2015...
Read more >var vs let vs const in JavaScript - ui.dev
Now that you understand the difference between var and let , what about const ? Turns out, const is almost exactly the same...
Read more >Use 'let' and 'const' instead of 'var' - Evert Pot
When you create an object with const , you can still change it's contents. const only prevents re-assigning, it doesn't make the entire...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@CreativeGP it would just be compiled back to
var
anyway for compatibility reasons. also, there are instances whereconst
andlet
won’t work, and onlyvar
will. here’s an example:https://github.com/r3wt/express-map/blob/master/index.js#L17
another common case is variables holding a primitive value that need to be “globally” scoped but modifiable from any child scope. you can’t use
const
orlet
for that. additionally, you can’t declareconst
orlet
inside of a switch statement.You entrust users to do it? So, how about improving the code of this repository with it?