Object.values and/or Object.forEach ?

Dean Landolt dean at deanlandolt.com
Fri Jun 7 10:18:59 PDT 2013


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.giammarchi at 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 at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130607/d46bc794/attachment-0001.html>


More information about the es-discuss mailing list