Standard built-ins
AsyncGenerator.prototype.return()
Requests completion and returns a promise for an iteration result; asynchronous cleanup may run.
Formal Syntax & Structure
javascript syntaxjavascript
asyncGenerator.return([value])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | any | Optional resumption, completion or error value. |
Return Value
Promise<IteratorResult>
Promise for the iteration result.
Working Example
Example Snippetjavascript
async function* g(){try{yield 1;}catch(e){yield e.message;}}(async()=>{const i=g();await i.next();console.log((await i.return(8)).value);})();