JS: Iterator Prototype

By Xah Lee. Date: . Last updated: .

New in ES2015.

Builtin iterators of JavaScript has a prototype object.

[see JS: 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.


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

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon