Object.values and/or Object.forEach ?

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Jun 7 09:57:24 PDT 2013


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 ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130607/12b8a466/attachment-0001.html>


More information about the es-discuss mailing list