How to make an iterator out of an ES6 class
You need to specify Symbol.iterator property for SomeClass which returns iterator for class instances. Iterator must have next() method, witch in turn returns object with done and value fields. Simplified example: function SomeClass() { this._data = [1,2,3,4]; } SomeClass.prototype[Symbol.iterator] = function() { var index = 0; var data = this._data; return { next: function() { … Read more