Generator issue: exceptions while initializing arguments

Brendan Eich brendan at mozilla.org
Sat Sep 8 20:47:11 PDT 2012


Brendan Eich wrote:
> function dataSnapshot(aCollection) {
>   var snapshot = aCollection.clone();
>   let i = 0;

let i = -1;

rather,

>   return {
>     next: function () {
>       if (++i == snapshot.length)
>         throw StopIteration;
>       return snapshot[i];
>     }
>   };
> }

or this might run a while!

/be


More information about the es-discuss mailing list