![]() |
JavaScript AsyncGenerator.prototype.next() method is used with the asynchronous generators to retrieve the next value in the sequence produced by the generator. It returns a Promise that resolves to the object with two properties: value and done. Syntax: AsyncGenerator.prototype.next(value);
Parameters: This method accepts only one parameter as shown in the above syntax and explained below:
Return Value: The return value is a Promise that resolves to an object with the two properties:
The below examples will explain the practical implementation of the AsyncGenerator.prototype.next() method. Example 1: In the below article, we will create a generator function and then use the next() method on it by creating an instance of it. Javascript
Output
3 false 5 false 3 false Example 2: This example will illustrate the use of the asyncGenerator function and the next() method with the string values. Javascript
Output
HI false Async false Generator false Supported Browsers: The browsers supported by Generator.prototype.next() method are listed below:
|
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |