question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why don't you replace `var` with `const` and `let`?

See original GitHub issue

Summary

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:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
r3wtcommented, May 4, 2018

@CreativeGP it would just be compiled back to var anyway for compatibility reasons. also, there are instances where const and let won’t work, and only var 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 or let for that. additionally, you can’t declare const or let inside of a switch statement.

1reaction
CreativeGPcommented, May 1, 2018

You entrust users to do it? So, how about improving the code of this repository with it?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found