{let i = 0; let sum = 0; while (i < 3) {const next = await iterator. But, there are several syntactical differences. This enables you to loop over something which returns an iterable of promises. The value of this expression is returned from the iterator. If you can't understand something in the article – please elaborate. Also, async generators can be used for processing streams of data that flow chunk-by-chunk. Asynchronous iteration allow us to iterate over data that comes asynchronously, on-demand. When you have an array of data, you typically use a forloop to iterate over its elements. Here is an example: The values now will come with a delay of a second between them. javascript documentation: Async Iterators. For sheer simplicity, omitting some important stuff, they are “functions that generate (yield) values”. 100 users) – “one page”, and provides a URL to the next page. In regular generators we can’t use await. The latter works as follows. This automatically makes the returned async generator objects async iterators. Every time the next method is called, its body is executed until the next yield expression. Instead it returns an iterator-object which adheres to the iterator protocol i.e. This carriers over to generators created with an async function — these async generators always yield a Promise object. For instance, we can make the range object generate values asynchronously, once per second, by replacing synchronous Symbol.iterator with asynchronous Symbol.asyncIterator: Now values come with a delay of 1 second between them. A JavaScript AsyncIterator is an object with a .next() method, which returns a PromiseFacebook