DEV Community

Chad Gauthier
Chad Gauthier

Posted on

I would tell you a joke about async javascript

const tellJoke = async () => {
  console.log("I would tell you a joke about async JavaScript...");
  try {
    const punchline = await getPunchline();
    console.log(punchline, '🥁 Ba-dum-da-cha!');
  } catch {
    console.log('Joke delivery failed: Maximum call stack size exceeded!');
  }
};

async function getPunchline() {
  console.log(await getPunchline()); // practice for good delivery
  return "But I'm still awaiting for the punchline.";
}

tellJoke();
Enter fullscreen mode Exit fullscreen mode

Top comments (0)