Favorites

JavaScript async function Statement

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
async function
JavaScript Functions and ClassesThis statement is supported by all modern browsers.
Updated 28th November 2026

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

const wait = (ms, v) => new Promise(r => setTimeout(() => r(v), ms));

async function loadProfile(id) {
  const user = await wait(150, { id, name: 'Sam' });
  const posts = await wait(150, ['Post A', 'Post B']);
  return { ...user, posts };
}

loadProfile(7).then(profile => console.log(profile));
console.log(loadProfile(1) instanceof Promise);

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.

This statement is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee