pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/async_function*

"https://developer.mozilla.org/favicon.ico" />

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. It’s been available across browsers since 2020년 1월.

async function* 키워드는 표현식 내부에서 비동기 제너레이터 함수를 정의하는데 사용됩니다.

시도해 보기

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® 2026 Language Specification
# sec-async-generator-function-definitions

브라우저 호환성

같이 보기

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy