Legacy generator objects

Firefox (SpiderMonkey) also implemented an earlier version of generators in JavaScript 1.7, where the star (*) in the function declaration was not necessary (you just use the yield keyword in the function body). However, legacy generators support has been removed since Firefox 58 (released on January 23, 2018) (bug 1083482).

Legacy generator methods

Generator.prototype.next()

Returns a value yielded by the yield expression. This corresponds to next() in the ES2015 generator object.

Generator.prototype.close()

Closes the generator, so that when calling next() an StopIteration error will be thrown. This corresponds to the return() method in the ES2015 generator object.

Generator.prototype.send()

Used to send a value to a generator. The value is returned from the yield expression, and returns a value yielded by the next yield expression. send(x) corresponds to next(x) in the ES2015 generator object.

Generator.prototype.throw()

Throws an error to a generator. This corresponds to the throw() method in the ES2015 generator object.