4 ms·
The problem is that this is more than just a syntactic difference. There's a chance it will take two ticks to resolve instead of one. For documentation purpose
by junon 6y ago
The problem is that this is more than just a syntactic difference. There's a chance it will take two ticks to resolve instead of one.
For documentation purposes, I recommend block-commenting the `async`:
const foo = /async/ () => new Promise(...);
- eloff 6y agoThat's not true if you just return the promise instead of using return await, right?
- junon 6y agoNo. `async` on a function automatically defers it even if the return value is immediate. > async function foo() { return "hello"; } foo().then(console.log); console.log("after") after hello
- whatl3y 6y agoI did not know this and appreciate the insight! Will definitely store this back of mind and try and remember to use block comments when needing to explicitly return a promise.