http://lmgtfy.com/?q=site%3Aesdiscuss.org+object.values

From: es-discuss [mailto:[email protected]] On Behalf Of Gijs 
Kruitbosch
Sent: Tuesday, May 26, 2015 10:33
To: [email protected]
Subject: Providing object iterators beyond just Object.keys()

Hello,
When writing JS loops over objects, given the environment I'm in, I find myself 
using the gecko/spidermonkey-only "Iterator()" construct a lot for loops or 
array comprehensions:
for (let [key, val] of Iterator(plainJSObject)) {
   // do stuff with both key and val
}
It seems the plan is to remove "Iterator()" (cf. 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator
 ).
Are there plans to add things like Object.values() (to produce 
Object.keys(obj).map(k => obj[k]) ) or Object.iterator (Object.keys(obj).map(k 
=> [k, obj[k]])) so as to enable such usecases to be written easily in ES7 or 
later? Obviously I can create my own iterator, but it starts to get tedious if 
I need to do this in every file where I need to iterate over an object's own 
(enumerable) properties...
(using Maps here is difficult because writing hardcoded nested structures of 
Maps is not nearly as neat as doing the same with Objects)
Gijs
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to