Re:JavaScript variables: var and let and const
by ht85 on Friday March 06, 2020 @04:33PM
(#22507524)
It would be nice if you could assign the result of a try / catch (or any block) to a variable, you can kind of emulate it with an IIFE:
[ Parent
| on HN ]
Re:JavaScript variables: var and let and const
by mschuetz on Friday March 06, 2020 @04:59PM
(#22507729)
That may be a nice addition to the "do expression" proposal for javascript: https://github.com/tc39/proposal-do-expressions
let x = do {
let tmp = f();
tmp * tmp + 1
};
Unfortunately it seems like the proposal doesn't get much attention.
Re:JavaScript variables: var and let and const
by eyelidlessness on Saturday March 07, 2020 @11:27AM
(#22512372)
It would be nice if every JS statement had an expression equivalent.