When writing async functions, there are differences between await vs return vs return await, and picking the right one is important. Let's start with this async function: async function waitAndMaybeReject() { // Wait one second await new Promise((r) => setTimeout(r, 1000)); // Toss a coin const isHeads = Boolean(Math.round(Math.random())); if (isHeads) return 'yay'; throw Error('Boo!'); } This ret
![await vs return vs return await](https://cdn-ak-scissors.b.st-hatena.com/image/square/275edb50d473e8e4acd3a8035eef743809f96ee2/height=288;version=1;width=512/https%3A%2F%2Fjakearchibald.com%2Fc%2Ficon-d166b7f8.png)