Object.values and/or Object.forEach ?

Dean Landolt dean at deanlandolt.com
Fri Jun 7 10:31:01 PDT 2013


That's what I meant by "the for/of iterators solve this nicely". I think I
might have accidentally edited away the most important part of that
sentence -- let me try again:

"this seems like a very handy cowpath to pave *for polyfills*"

This way old code can get the benefit of this painfully common idiom too
(without the more heavyweight preprocessing necessary for polyfilling
import syntax).


On Fri, Jun 7, 2013 at 1:25 PM, Brandon Benvie <bbenvie at mozilla.com> wrote:

> On 6/7/2013 10:18 AM, Dean Landolt wrote:
>
>> The for/of iterators solve this nicely. This is definitely something that
>> comes up a lot though, and this seems like a very handy cowpath to pave. If
>> it were spec'd I'd suggest the naming and argument values should align with
>> the for/of variants.
>>
>
> My impression was that the @dict module solves this as you suggest.
>
>     import { keys, values, entries } from '@dict';
>
>     let obj = { a: 1, b: 2, c: 3 };
>
>     for (let key of keys(obj)) {
>       // ['a', 'b', 'c']
>     }
>
>     for (let value of values(obj)) {
>       // [1, 2, 3]
>     }
>
>     for (let [key, value] of entries(obj)) {
>       // [['a', 1], ['b', 2], ['c', 3]]
>
>     }
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130607/7636e0e7/attachment-0001.html>


More information about the es-discuss mailing list