Knowledgize

Iterable Object

An iterable object is any object that implements the iterable protocol. This means the object must have a Symbol.iterator method that returns an iterator object. Common examples of iterable objects include:


  • Arrays.
  • Strings.
  • Maps and Sets.
  • Typed arrays (e.g., Uint8Array, Float32Array).

Example

Here’s an example using a string (which is an iterable object):

const str = "hello"; const strArray = Array.from(str); console.log(strArray); // ['h', 'e', 'l', 'l', 'o']