Why not use the new meta syntax?

for (let value of values) {
  console.log(for.index);
}


- Matthew Robb

On Tue, Jul 14, 2015 at 7:45 AM, Jonathan Bond-Caron <
[email protected]> wrote:

> On Mon Jul 13 10:22 PM, Kevin Smith wrote:
>
> > Destructuring is here to help:
> >
> >     for (let [index, value] of [1, 2, 3].entries())
> >         console.log(index + ": " + value)
> >
> > The "entries" method returns an iterator of [index, value] pairs.
> >
>
> Can't there be a 'key iterator' syntax?
>
> for (let value, index of [1, 2, 3])
>          console.log(index + ": " + value)
>
> let value = itOfValues.next().value;
> let index= itOfKeys.next().value;
>
> - An array has an implicit 'key iterator' cause there's a key for each
> value.
> - Everything else has a 'keyIteratorFrom0ToInifinity'
>
> So you have a 'value iterator' and a 'key iterator' for each thing on the
> RHS.
> Doesn't seem like much of an issue, engines just need a
> keyIteratorFrom0ToInifinity for non-array things cases.
>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to