Open In App

JavaScript TypeError – ‘X’ is not iterable

Last Updated : 22 May, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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

Previous Article
Next Article

Similar Reads

JavaScript TypeError - "X" is (not) "Y"
This JavaScript exception X is (not) Y occurs if there is a data type that is not expected there. Unexpected is undefined or null values. Message: TypeError: Unable to get property {x} of undefined or null reference (Edge) TypeError: "x" is (not) "y" (Firefox) Few example are given below: TypeError: "x" is undefined TypeError: "y" is null TypeError
1 min read
JavaScript TypeError - "X" is not a constructor
This JavaScript exception is not a constructor that occurs if the code tries to use an object or a variable as a constructor, which is not a constructor. Message: TypeError: Object doesn't support this action (Edge) TypeError: "x" is not a constructor TypeError: Math is not a constructor TypeError: JSON is not a constructor TypeError: Symbol is not
1 min read
JavaScript TypeError - "X" is not a function
This JavaScript exception is not a function that occurs if someone trying to call a value from a function, but in reality, the value is not a function. Message: TypeError: Object doesn't support property or method {x} (Edge) TypeError: "x" is not a function Error Type: TypeError Cause of Error: There is an attempt to call a value from a function, b
1 min read
JavaScript TypeError - "X" is not a non-null object
This JavaScript exception is not a non-null object that occurs if an object is not passed where it is expected. So the null is passed which is not an object and it will not work. Message: TypeError: Invalid descriptor for property {x} (Edge) TypeError: "x" is not a non-null object (Firefox) TypeError: Property description must be an object: "x" (Ch
1 min read
JavaScript TypeError - Can't assign to property "X" on "Y": not an object
This JavaScript exception can't assign to property occurs in strict-mode only and this error occurs If the user tries to create a property on any of the primitive values like a symbol, a string, a number, or a boolean. Primitive values cannot be used to hold any property. Message: TypeError: can't assign to property "x" on {y}: not an object (Firef
1 min read
JavaScript TypeError - Can't define property "X": "Obj" is not extensible
This JavaScript exception can't define property "x": "obj" is not extensible occurs when Object.preventExtensions() is used on an object to make it no longer extensible, So now, New properties can not be added to the object. Message: TypeError: Cannot create property for a non-extensible object (Edge) TypeError: can't define property "x": "obj" is
1 min read
JavaScript: Uncaught TypeError: n is not a function
This is a standard JavaScript error when trying to call a function before it is defined. This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the expression did not return a function object. So you need to understand that what you are trying to achieve is not a feature. Message:
3 min read
JavaScript TypeError - Reduce of empty array with no initial value
This JavaScript exception reduce of empty array with no initial value occurs if a reduce function is used with the empty array. Message: TypeError: reduce of empty array with no initial value Error Type: TypeError Cause of Error: This error is raised if an empty array is provided to the reduce() method because no initial value can be returned in th
1 min read
JavaScript TypeError - "X" has no properties
This JavaScript exception null (or undefined) has no properties that occur if there is an attempt to access properties of null and undefined. They don't have any such properties. Message: TypeError: Unable to get property {x} of undefined or null reference (Edge) TypeError: null has no properties (Firefox) TypeError: undefined has no properties (Fi
1 min read
JavaScript TypeError - "X" is read-only
This JavaScript exception is read-only works in strict mode-only and It occurs if a global variable or object property which has assigned to a value, is a read-only property. Message: TypeError: Assignment to read-only properties is not allowed in strict mode (Edge) TypeError: "x" is read-only (Firefox) TypeError: 0 is read-only (Firefox) TypeError
1 min read