Iteration (was: Re: Object.values and/or Object.forEach ?)

Axel Rauschmayer axel at
Sat Jun 8 22:20:40 PDT 2013

>>> 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.

With ES6 iteration protocols, we’ll face an interesting (and difficult) decision in the future: Should my function/method compute its results eagerly and return a data structure such as an array or should it compute its results lazily and return an iterable? Having two versions of everything doesn’t seem desirable to me and fortunately, converting a lazy iterable to an array is not too inconvenient.

I would, however, love to have a naming convention that indicates that a function/method works lazily. For example: `values` (eager) versus `valueIter` (lazy).

Dr. Axel Rauschmayer
axel at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list