Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit 89690a7

Browse files
author
Willian Martins
committed
Adding Symbol.asyncIterator example
1 parent 4728786 commit 89690a7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

live-examples/js-examples/symbol/meta.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"pages": {
3+
"symbolAsyncIterator": {
4+
"exampleCode": "./live-examples/js-examples/symbol/symbol-async-iterator.html",
5+
"fileName": "symbol-async-iterator.html",
6+
"title": "JavaScript Demo: Symbol.asyncIterator",
7+
"type": "js"
8+
},
39
"symbolConstructor": {
410
"exampleCode": "./live-examples/js-examples/symbol/symbol-constructor.html",
511
"fileName": "symbol-constructor.html",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<pre>
2+
<code id="static-js">const asyncIterableObj = new Object();
3+
4+
asyncIterableObj[Symbol.asyncIterator] = async function* () {
5+
yield 1;
6+
yield 2;
7+
yield 3;
8+
};
9+
10+
(async function () {
11+
for await (let num of asyncIterableObj) {
12+
console.log(num);
13+
}
14+
})();
15+
// expected output:
16+
// > 1
17+
// > 2
18+
// > 3
19+
</code>
20+
</pre>

0 commit comments

Comments
 (0)