News for hackers. Stuff that matters.
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.