Saturday, November 22, 2025
HomeLanguagesJavascriptJavaScript Symbol asyncIterator Property

JavaScript Symbol asyncIterator Property

JavaScript Symbol asyncIterator property is used to set an object as an async iterable. Iterable properties of this object can be iterated over using a for await…of loop.

An async iterable object is any object that returns a function that produces an AsyncIterator for its Symbol.asyncIterator property.

The Symbol.asyncIterator symbol is a built-in symbol that is used to access an object’s @@asyncIterator method. 

Note: For an object to be an async iterable, it must have a Symbol.asyncIterator key.

Property attributes of Symbol.asyncIterator
Writable no
Enumerable no
Configurable no

Example codes for the above property are as follows:

Example 1:

Javascript




const GFG = {
    async*[Symbol.asyncIterator]() {
        let i = 0;
        while (i < 10) {
            if (i % 3 == 0) {
            yield i;
        }
        i++;
    }
}
  
};
  
(async () => {
    for await (const x of GFG) {
    console.log(x);
    }
})();


Output: 

0
3
6
9

Example 2:

Javascript




const myAsyncIterable = {
  
  async*[Symbol.asyncIterator]() {
  
      let i = 0;
      while (i < 5) {
        yield i++;
      }
  }
};
  
(async () => {
  for await (const num of myAsyncIterable) {
  console.log(num + "<br>");
  }
})();


Output

0
1
2
3
4

Browser Support: The browsers supported by JavaScript Symbol.asyncIterator Property are listed below:

  • Google Chrome
  • Firefox
  • Edge
  • Opera
  • Safari

We have a complete list of Javascript symbols’ properties and methods, to check those please go through the Javascript Symbol Complete Reference article.

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6784 POSTS0 COMMENTS
Nicole Veronica
11931 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11999 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6863 POSTS0 COMMENTS
Umr Jansen
6848 POSTS0 COMMENTS