Iterable protocol
The iterable protocol is the JavaScript protocol by which an object provides a method keyed by Symbol.iterator that returns an iterator.
The Joy of JavaScript
Symbol.iterator is a built-in JavaScript symbol that defines the method an object uses to provide its iterator.
- How it is used
- Customizes how objects participate in for...of loops, spread expressions, and destructuring.
- How deep it goes
- Defines Symbol.iterator, iterator results, delegation, and generators, while deferring detailed generator and asynchronous treatment.
- Examples
- Uses strings, Blockchain, Block, Transaction, Pair, and Validation to demonstrate delegation, termination, generators, and destructuring.
- What you can do after
- Apply it via JavaScript to build custom objects that work with standard iteration syntax and composable data-processing patterns.
Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
The well-known property name that an iterable object exposes to supply an iterator in JavaScript.
- How it is used
- Enables objects to supply values to `for...of` and spread through a common protocol.
- How deep it goes
- Explains the `Symbol.iterator` method, `next()` results, and completion, then demonstrates manual and generator-based implementations.
- Examples
- Uses array indices versus values, a three-prime iterable, a customized string iterator, and a bounded-iteration exercise.
- What you can do after
- Build it from scratch by supplying `Symbol.iterator`, or customize an existing iterable’s yielded values.
Related concepts
- iterableused by · An iterable is an object or value that provides or supports a protocol for producing its elements sequentially.
- Validationimplemented by · Validation is a computation or value type representing either a successful result or failure information while supporting successful processing and failure propagation or accumulation.
- destructuring assignmentused by · Destructuring assignment is syntax that decomposes a structured value according to a pattern and binds selected components to names.
- value propertyproduces · The value property is the field of an iterator result object that contains the item produced for the current iteration step.
- doneproduces · done is a Boolean property of an iterator result that indicates whether the iterator has finished producing values.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

