Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Awaiting a non-promise doesn’t make it synchronous, though — it still executes any subsequent lines in a microtask.

Try running this code. It’ll print “bar” first and then “foo”, even though the function only awaits a string literal and the caller doesn’t await anything at all.

  const foo = async () => console.log(await "foo");

  foo();
  console.log("bar");


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: