What is the async await equivalent of Promise.resolve().then() in JavaScript?

Sometimes, we want to find the async and await equivalent of Promise.resolve().then() in JavaScript.

In this article, we’ll look at how the async and await equivalent of Promise.resolve().then() in JavaScript.

What is the async await equivalent of Promise.resolve().then() in JavaScript?

The async and await equivalent of Promise.resolve().then() in JavaScript is the following:

const fn = async () => {}

(async () => {
  await fn()
})()

fn is the same as Promise.resolve which returns a promise that resolves to an empty value.

We call it and use await so that we wait until fn resolves until we run the next line of code.

Conclusion

The async and await equivalent of Promise.resolve().then() in JavaScript is an async function that returns nothing and adding await before the async function call.