Thursday, January 29, 2026
HomeLanguagesJavascriptJavaScript TypeError – ‘X’ is not iterable

JavaScript TypeError – ‘X’ is not iterable

This JavaScript exception is not iterable occurs if the value present at the right-hand-side of for…of or as argument of a function such as Promise.all or TypedArray.from, can not be iterated or is not an iterable object.

Message:

TypeError: 'x' is not iterable (Firefox, Chrome)
TypeError: 'x' is not a function or its return value is not iterable (Chrome)

Error Type:

TypeError

Cause of Error: Somewhere in the code, the value present at the right-hand-side of for…of or as argument of a function such as Promise.all or TypedArray.from, is used like it can be iterated or is an iterable object.

Example 1: In this example, the GFG_Obj is not iterable, So the error has occurred.

Javascript




let GFG_Obj = { 'prop1': 'val1', 'prop2': 'val2' };
// TypeError: GFG_Obj is not iterable
for (let x of GFG_Obj) {
    // Do Anything.
}


Output(in console):

TypeError: GFG_Obj is not iterable

Example 2: In this example, the GFG is not iterable, So the error has occurred.

Javascript




function* GFG(a, b) {
    yield a;
    yield b;
}
// TypeError: GFG is not iterable
for (let y of GFG)
    console.log(x);


Output(in console):

TypeError: GFG is not iterable
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6848 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6916 POSTS0 COMMENTS