JavaScript: Iterator Prototype

By Xah Lee. Date: . Last updated: .

New in ES2015.

Builtin iterators of JavaScript has a prototype object.

〔►see JavaScript: Iterator

The Iterator Prototype object is denoted as “%IteratorPrototype%” by the JavaScript spec.

There's no direct syntax for it. But you can get it by

const iteratorProto = Object.getPrototypeOf ( Object.getPrototypeOf ( [][Symbol.iterator] ) );

You can add properties to this iterator prototype, so all builtin iterators will inherit it.

Reference

ECMAScript® 2016 Language Specification#sec-%iteratorprototype%-object

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.