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.
On Fri, Jun 7, 2013 at 12:57 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > it comes out from time to time devs would like to have `Object.values()` > as equivalent of `Object.keys()` except the returned array would contain > values. > > Better than repeated > `Object.keys(obj).map(function(p){return this[k];}, obj);` > all over > > but probably less useful than a more generic `Object.forEach(obj, > callback, thisValue)` where `callback` would receive `(value, key, > originalObject)` and `thisValue` as context. > > This is consistent with `Array#forEach` and could simplify `for/in` loops > passing over own enumerable properties only, as keys would do. > > Thoughts ? > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss