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.

`let` over `var`?

See original GitHub issue

I notice in the examples const is used but in the source var is all over the place. I suppose this is one of those why-fix-it-if-it-works things, but I have to ask what was the thinking behind using the more problematic, functionally scoped var over let?

Truth be told I am convinced (and helping to convince my students) of the dangers of var in general and that its time has past. Am I missing a solid reason not to say this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rwxrobcommented, Nov 23, 2017

Makes sense. I was confused by the use of const (a JavaScript 2015 thing along with let) in the example code in the main readme. That implied an assumption of at least that version required in the framework.

[I have been looking for a framework written in ES6 to use because I have no desire to promote further use of any previous standard despite backward compatibility issues. I realize that is not for everyone. I was kinda hoping as new as hyperapp is that it might be one brave enough to throw off the old—especially after reading the ‘drop JSX’ thread. 😁 ]

0reactions
Swizzcommented, Nov 24, 2017

To follow backward compatibility ES6 come with most of the ES5 feature. So writing ES5 is actually writing ES6.

I mean by that you can still use var and claim you are using ES6 as let, const and var are part of the specification. They are all three a different meaning.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advantages of using let over var within a function [duplicate]
Advantages of using let over var within a function [duplicate] · As per this answer they are identical within a function like yours....
Read more >
Var, Let, and Const – What's the Difference? - freeCodeCamp
var variables can be updated and re-declared within its scope; let variables can be updated but not re-declared; const variables can neither be ......
Read more >
let - JavaScript - MDN Web Docs
let allows you to declare variables that are limited to the scope of a block statement, or expression on which it is used,...
Read more >
Difference between var and let in JavaScript - GeeksforGeeks
Variable declared by let cannot be redeclared and must be declared before use whereas variables declared with var keyword are hoisted.
Read more >
JavaScript: Var, Let, or Const? Which One Should you Use?
Use let when you know that the value of a variable will change. Use const for every other variable. Do not use var....
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