Skip to content

isIterable ​

The isIterable function checks if a value is iterable (has the Symbol.iterator method).

Syntax ​

typescript
isIterable(value: any): value is Iterable<any>;

Parameters ​

NameTypeDescription
valueanyValue to be checked

Returns ​

TypeDescription
booleanReturns true if the value is iterable

Examples ​

typescript
isIterable([1, 2, 3]); // => true
isIterable('abc'); // => true
isIterable(123); // => false
isIterable({}); // => false

Notes ​

  • Iterables include arrays, strings, Maps, Sets, etc.
  • Useful for validation before using for...of loops.

References ​

Released under the MIT License.