News for hackers. Stuff that matters.
Re:What’s New in ES2019 by heavenlyblue on Tuesday July 30, 2019 @08:47AM (#20564297)
The truth is that if you need to declare a variable outside your current scope you should probably declare it in the outside scope in the first place.

In the scenario with var/let I need to grok the code in order to tell which variables are visible in my current scope.

Re:What’s New in ES2019 by jarekkruk on Tuesday July 30, 2019 @03:05PM (#20568077)
I tend to mainly use const, let only when necessary. I never use var and set linter to scream about it at me. IE11 supports it, so unless you develop application for IE compatibility mode (my condolences) I don't see a reason to use var. On the other hand var mainly bites you when declaring closures inside loops, also hoisting is just plain weird.
Re:What’s New in ES2019 by z3t4 on Wednesday July 31, 2019 @07:15AM (#20573350)
I find hoisting a convenient feature as I can declare the variable in context to where it's used. It means I do not have to break the flow of how the code reads, making the code easier to understand and less bug prone. Example:

    if(something) var foo = 1;
Re:What’s New in ES2019 by heavenlyblue on Wednesday July 31, 2019 @07:52AM (#20573556)
So how do you maintain the invariant that this variable is used only if <something> is true _down the line_?
Re:What’s New in ES2019 by z3t4 on Wednesday July 31, 2019 @07:54PM (#20579897)
It's only logical that it will be undefined if it's never assigned. With var you can just declare anywhere. While with let it feels like a chore when you have to declare in a parent block, eg. outside the if-block for it to be accessible within another if-block. Lexical function scope works very well in an async language with first class functions, as you deal mostly with functions, which can access it's closures at any time, etc. makes it logical that the function should define the scope, not if-statement or for-loops.