Sam Littlefair

Sam's Personal Website

Tags
  • coding

Josh Comeau is an amazing educational writer, and each blog post he releases generates crazy buzz on Twitter. He's great and choosing sticky concepts and explaining them so they feel intuitive.

Josh just released a new post about JavaScript promises, which (I hope) made them click for me. I now understand how and why this:

async function addNums(a, b) {
  return a + b;
}

Is equivalent to this:

function addNums(a, b) {
  return new Promise((resolve) => {
    resolve(a + b);
  });
}
© Sam Littlefair 2025