Object.values and/or Object.forEach ?

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Sat Jun 8 22:02:47 PDT 2013


On Jun 8, 2013, at 9:52 PM, Axel Rauschmayer wrote:

>> Why refuse a convenient library method and force users to
>> 1) let values = [];
>> 2) for (v of values(o)) { values.push(v); }
>> , if it can be just let values = Object.values(o);?
> 
> 
> Note that you can do either of the following:
> 
>     let values = [...values(o)];
>     let values = Array.from(values(o));

Thanks. I though mentioned also, there is no big need to provide some alternative fancy examples of doing some action in JS. I'm pretty sure everyone on this list know/understand how the designed methods (which are discussed on this list) work and how they can be applied in alternative ways. And I also don't wanna bikeshead on how this two lines are better than Object.values(...) from the user-level perspective.

I'm not super concern about having this or that API method, but I just don't a reason not to have one if it's convenient and may help to make developers' live easier.

Anyways, cool example though, thanks for sharing.

Dmitry


More information about the es-discuss mailing list