JavaScript AsyncGenerator Methods

Beginner
4 min read
Updated: Nov 2026
3 method guides
Method index

About This Index

This page is the JavaScript AsyncGenerator Methods index. Every object returned by an async function* has three methods, and each row below links to a full guide with syntax, examples you can run, and FAQs.

Learn what an async generator is on /js/async-generator. Use this page when you need a specific method such as next().

All three methods return a Promise.

Each one resolves to an object { value, done }, or rejects when the generator throws an error it did not catch. Always await the call or add .then().

How to Call an AsyncGenerator Method

Call the methods on the object an async function* returns, inside an async function (or a module) so you can await them:

JavaScript
async function* feed() {
  try {
    yield "a";
    yield "b";
  } finally {
    console.log("cleanup");
  }
}

const gen = feed();

// read: run to the next yield
const step = await gen.next();          // { value: "a", done: false }

// talk back: the paused yield evaluates to "reply"
const reply = await gen.next("reply");  // { value: "b", done: false }

// finish early: "cleanup" runs, then { value: "stop", done: true }
const end = await gen.return("stop");

// or signal a problem at the paused yield instead:
// await gen.throw(new Error("timeout"));

JavaScript AsyncGenerator Methods Table

All method guides in this JavaScript tutorial series (3 tutorials), grouped by what they do.

Resume and read values

1 method

Move the generator forward one step and receive the next value, optionally sending a value back in.

MethodDescriptionTutorial
next()Resume to the next yield; resolves to { value, done }. next(value) sends a value into the paused yield.Open

Finish or signal the generator

2 methods

End the generator early with cleanup, or report a problem at the point where it is paused.

MethodDescriptionTutorial
return()Finish now; finally blocks run and the promise resolves to { value, done: true }.Open
throw()Throw an error at the paused yield; the generator can catch it and continue, or finish with a rejection.Open

Frequently Asked Questions

Three public methods: next() to resume and read the next value, return() to finish early, and throw() to raise an error at the paused yield. It also has a [Symbol.asyncIterator]() method that returns the object itself, which is what makes for await...of work.
The AsyncGenerator page explains the idea: async function*, for await...of, queueing, and cleanup, with beginner examples. This index lists the method guides so you can jump straight to next(), return() or throw().
Yes. next(), return() and throw() each return a Promise that resolves to { value, done }. The promise rejects when the generator throws an error it does not catch, for example after throw() with no matching catch block.
It calls next() for every step and return() when you leave the loop early with break, return, or an error. It never calls throw(); you call that one yourself.
Start with next(), because return() and throw() build on it. Then read return() for early exits and cleanup, and throw() for sending errors into a generator.

Start with next()

Open the guide for reading values one step at a time: syntax, examples, and FAQs.

next() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful