Firefox: for-of and objects

Jason Orendorff jason.orendorff at gmail.com
Thu Oct 25 08:50:15 PDT 2012


On Thu, Oct 25, 2012 at 6:24 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
> Sorry, slightly off-topic: Does Firefox already have @iter.items (etc.)? Or
> is there something similar one could use to iterate over [key, value] pairs
> for objects, via for-of?

Unfortunately Iterator does do that, but I tend to think you'd be
better off using Object.keys. Of course you can also write your own:

function items(obj) {
    return [[k, obj[k]] for (k of Object.keys(obj))];
}

-j


More information about the es-discuss mailing list