Questions/issues regarding generators

André Bargull andre.bargull at udo.edu
Sat Mar 30 07:05:46 PDT 2013


> >>/  The most significant change from the meeting (and it really wasn't
> />>/  explicit on the whiteboard) is that generator prototypes don't have a
> />>/  "constructor" property that links back to its generator function instance.
> />>/   In other words, you can't say:
> />>/
> />>/  function * ofCollection() {for (i of collection) yield i};
> />>/  var itr1 = ofCollection();
> />>/  var itr2 = iter1.constructor();  //TypeError
> />>/
> />/
> />/  That wouldn't be a type error. It would be invoking the value of the
> />/  inherited generator property.
> />/
> /
> Sorry, "...inherited *constructor* property" that is.

But the inherited constructor property is not callable, so it's still a 
TypeError:

> js> function * ofCollection() {for (let i of collection) yield i}; js> 
> var itr1 = ofCollection(); js> var itr2 = itr1.constructor(); uncaught 
> exception: TypeError: object is not a function


- André

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130330/2b6c4abe/attachment.html>


More information about the es-discuss mailing list