Re:Mistakes we make using JavaScript Promises
by orf on Friday July 05, 2019 @05:17AM
(#20361028)
Async/await is inherently better than other syntax though, for a number of reasons, and the interpreter does indeed know the difference. If anything the interpreter knows much more about your intent, rather than “oh this function takes a `callback` parameter that’s a function” and can optimize based on that info.
[ Parent
| on HN ]
Re:Mistakes we make using JavaScript Promises
by gatherhunterer on Friday July 05, 2019 @09:34AM
(#20362368)
It is not better, the two have different use cases. If you are using setTimeout to delay then you need a callback. Being so obsessed with the syntax that you right your code twice is the only wrong solution. While the AsyncFunction is used only by async statements and expression it uses Promise under the hood. In terms of performance it is not a good idea to make assumptions like that, performance can only be determined by testing.