5 ms·
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: const outer = (() =
by ht85 7y ago
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:
const outer = (() => {
try {
...
return ...
} catch (error) {
...
}
})()
- mschuetz 7y agoThat may be a nice addition to the "do expression" proposal for javascript: https://github.com/tc39/proposal-do-expressions 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.
- eyelidlessness 7y agoIt would be nice if every JS statement had an expression equivalent.