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 iterablefor(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 iterablefor(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, zambiatek 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!
 
				 
					

