TypeError not iterable JavaScript Origin: On your device Last updated 15 Oct 2026

TypeError: x is not iterable

for…of, spread or destructuring was used on something that isn’t an array/iterable.

Exact message you may see is not iterableobject is not iterableundefined is not iterable
Seen on: JavaScript

Meaning

Plain objects, undefined and numbers aren’t iterable. Common when an API returns an object instead of an array, or data hasn’t loaded.

Common causes

  • Spreading/looping undefined (data not loaded)
  • Iterating a plain object instead of Object.entries()
  • Destructuring a hook that returns an object as an array
  • API shape changed

⚡ Quick fix

  1. Default to []: for (const x of items ?? [])
  2. Use Object.entries/keys/values for objects
  3. Log the value to confirm its type

Detailed fix by platform

JavaScript

  1. for (const [key, value] of Object.entries(config)) { … }

How to diagnose

  1. Value — What is it actually?
  2. Source — API, props or state?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

addEventListener on null — TypeError: Cannot read properties of null (reading 'addEventListener') (JavaScript)addEventListener on n…Array offset on null — Warning: Trying to access array offset on value of type null (PHP)Array offset on nullObject.keys null — TypeError: Cannot convert undefined or null to object (JavaScript)Object.keys nullreading length — TypeError: Cannot read properties of undefined (reading 'length') (JavaScript)reading lengthRuntimeError dict — RuntimeError: dictionary changed size during iteration (Python)RuntimeError dictTS2532 / TS18048 — TS18048: 'x' is possibly 'undefined'. (TS2532: Object is possibly 'undefined'.) (Node.js)TS2532 / TS18048TypeError — TypeError: Cannot read properties of undefined (reading 'x') (JavaScript)TypeErrorTypeError set undefined — TypeError: Cannot set properties of undefined (setting 'x') (JavaScript)TypeError set undefin…TypeError…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.