๐ฐiterable
an object that can iterate over itself.
Last updated
Was this helpful?
an object that can iterate over itself.
Last updated
Was this helpful?
Was this helpful?
an object that can make iterators. (like Sequence in Swift, must implement .makeIterator() method)
for (const value of iterable) { ... } // for-of
[...iterable] // spread into array elements
f(...iterable) // spread into function arguments
const [a, b, c] = iterable; // destructuring iterable
Array.from(iterable) // iterable -> array
(by default) object is not iterableโ
let obj = { x: 1, y: 2, z: 3 };
for (let value of obj) { } // โ TypeError
// โญ๏ธ workarounds
for (
f(...
iterable
)
- spread into function arguments.
const [a, b, c] =
iterable
;
- iterable destructuring.
Array.from(
iterable
)
- convert to array.
ClosedRange - closed range of integers.