3 ms·
The trouble with async/await is to use it properly you really need to understand promises. For example, many people are stumped why you can't await inside of Ar
by city41 6y ago
The trouble with async/await is to use it properly you really need to understand promises. For example, many people are stumped why you can't await inside of Array#map. I've always felt it's a leaky abstraction and I personally prefer to just use promises most of the time. I do find async/await a great fit for say puppeteer tests where the entire test is a long run of blocking async calls.
- Kaze404 6y ago> many people are stumped why you can't await inside of Array#map Isn't that solved with a simple google search? Async/await makes the function return promises, so if you use an async callback in Array#map you end up with an array of promises, which you can use with Promise#all. Seems rather simple to explain and grok.
- johnsonjo 6y agoI don’t know much about compiler internals, but this sounds like it could complicate a lot of things and not have as many guarantees that the compiler could assume (thus since JS interprets code it could slow down runtime performance). I don’t know though maybe someone more in the compiler space could answer.