We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

Our volunteers haven't translated this article into عربي yet. Join us and help get the job done!
You can also read the article in English (US).

The await operator is used to wait for a Promise. It can only be used inside an async function.


[rv] = await expression;
A Promise or any value to wait for.

Returns the fulfilled value of the promise, or the value itself if it's not a Promise.


The await expression causes async function execution to pause until  a Promise is fulfilled, that is resolved or rejected, and to resume execution of the async function after fulfillment. When resumed, the value of the await expression is that of the fulfilled Promise.

If the Promise is rejected, the await expression throws the rejected value.

If the value of the expression following the await operator is not a Promise, it's converted to a resolved Promise.


If a Promise is passed to an await expression, it waits for the Promise to be fulfilled and returns the fulfilled value.

function resolveAfter2Seconds(x) { 
  return new Promise(resolve => {
    setTimeout(() => {
    }, 2000);

async function f1() {
  var x = await resolveAfter2Seconds(10);
  console.log(x); // 10

If the value is not a Promise, it converts the value to a resolved Promise, and waits for it.

async function f2() {
  var y = await 20;
  console.log(y); // 20

If the Promise is rejected, the rejected value is thrown.

async function f3() {
  try {
    var z = await Promise.reject(30);
  } catch(e) {
    console.log(e); // 30

Handle rejected Promise without try block.

var response = await promisedFunction().catch((err) => { console.log(err); });
// response will be undefined if the promise is rejected


Specification Status Comment
ECMAScript Latest Draft (ECMA-262)
The definition of 'async functions' in that specification.
Draft Initial definition in ES2017.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support55 Yes52 ?4210.1
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support5555 Yes524210.1 ?

See also

Document Tags and Contributors

 المساهمون في هذه الصفحة: Jun711, isikfsc, wnavarre, 54huanan, domleonard, fscholz, jpmedley, fkling42, jameshkramer, Venryx, nmve, daytonlowell, past, arai
 آخر مَن حدّثها: Jun711,