3 ms·
Some language features aren’t aimed at toy examples, and if that’s the scope of your thinking, you won’t see the point. For example, I like how the catch block
by codeflo 4y ago
Some language features aren’t aimed at toy examples, and if that’s the scope of your thinking, you won’t see the point.
For example, I like how the catch block is just a single function call to handleErrorSomehow — which would be totally fine for an example, if it weren’t for the fact that the author makes a special note of how convenient it is that the Promise variant reduces to just .catch(handleErrorSomehow). Suuuper-realistic.
I should probably admit that I also didn’t completely see the point of async/await — this was years ago in C# — until I first had a chance to use it inside a
complex loop of some kind. I think it’s a good exercise to try manually desugaring such an example. It really makes you appreciate what the compiler’s doing for you in these cases.