Re:A Modern JavaScript Tutorial
by jedimastert on Monday December 07, 2020 @12:14PM
(#25334190)
Can you point to anything other than saying "this is obvious"?
[ Parent
| on HN ]
No, just experience with a lot of codebases.
Here's a simple question to ask yourself: what if non-IO operations allowed you to use the .then() syntax? If you have the choice to use:
1 + 1.then(function(result) { ... }
vs const result = 1 + 1
Which would you choose?Using then() doesn't pause execution of the callsite function, while await does. Surely that's a relevant difference here?
It doesn't seem unreasonable to use then() to express: "Run this anonymous function whenever the async thing completes. Meanwhile let's do this other stuff right now."