JavaScript async function Statement
An async function always returns a promise and can use await inside it to wait for other promises, so asynchronous code reads like ordinary step-by-step code.
Description
An async function declaration defines a function that always returns a promise. A returned value fulfills the promise, and a thrown error rejects it. Inside, the await operator pauses the function until a promise settles, so a sequence of asynchronous steps can be written top to bottom, with errors handled by try...catch.
Arrow functions and methods can be async too: async () => {}. Calling an async function starts it immediately and returns the promise straight away; the caller continues without waiting unless it uses await or then().
Error handling in async functions works with ordinary try...catch blocks around await expressions. If you don't catch an error, the returned promise rejects, and if nothing handles that rejection, the browser reports an "unhandled promise rejection". Each await pauses only the current function, so awaiting independent tasks one after another is slower than starting them together and awaiting Promise.all(). Modules can also use await at the top level, outside any function.
Syntax
async function name(params) {
const result = await promise;
return value;
}Example
Browser Support
The following information will show you the current browser support for the async function statement. Hover over a browser icon to see the version that first introduced support for this statement.
Desktop





Tablets & Mobile





