[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/async_function* [Back]  [Original]

async function* - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

async function*

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2020 1.

async function* .

In this article

async function* foo() {
  yield await Promise.resolve("a");
  yield await Promise.resolve("b");
  yield await Promise.resolve("c");
}

let str = "";

async function generate() {
  for await (const val of foo()) {
    str = str + val;
  }
  console.log(str);
}

generate();
// Expected output: "abc"

js
async function* (param0) {
  statements
}
async function* (param0, param1) {
  statements
}
async function* (param0, param1, /*  ,*/ paramN) {
  statements
}

async function* name(param0) {
  statements
}
async function* name(param0, param1) {
  statements
}
async function* name(param0, param1, /*  ,*/ paramN) {
  statements
}

name Optional

. . .

paramN Optional

. 255 .

statements Optional

.

async function* async function* statement . , async function* . .

async function*

x , .

js
const x = async function* (y) {
  yield Promise.resolve(y * y);
};
x(6)
  .next()
  .then((res) => console.log(res.value)); // 36

Specification
ECMAScript 2027 LanguageSpecification
# sec-async-generator-function-definitions


Web Proxy Viewer  |  New URL  |  Original Page