Object.values and/or Object.forEach ?

Brandon Benvie bbenvie at mozilla.com
Fri Jun 7 10:25:21 PDT 2013


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]]
     }


More information about the es-discuss mailing list