iterating through object property values

2014-12-03 Thread Mark Volkmann
It seems the typical way to do this is:

Object.keys(myObj).forEach(key = {
  let value = myObj[key];
  // Do something with value and/or key.
});

I don't see a new way to do this in ES6.

Is it still being considered to add the methods entries and values to
Object that return iterators?

-- 
R. Mark Volkmann
Object Computing, Inc.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: iterating through object property values

2014-12-03 Thread Caitlin Potter
It seems a bit late to add a default @@iterator to Object.prototype, but I 
guess it could work similar to Map.prototype.entries, if such a thing were to 
be added.

Have to be really careful adding things to Object.prototype, though — even when 
they’re non-enumerable, they can cause unexpected problems in code (code which 
probably ought to be using Object.create(null), but you know, doesn’t).

Caitlin Potter

 On Dec 3, 2014, at 12:07 PM, Mark Volkmann r.mark.volkm...@gmail.com wrote:
 
 It seems the typical way to do this is:
 
 Object.keys(myObj).forEach(key = {
   let value = myObj[key];
   // Do something with value and/or key.
 });
 
 I don't see a new way to do this in ES6.
 
 Is it still being considered to add the methods entries and values to 
 Object that return iterators?
 
 -- 
 R. Mark Volkmann
 Object Computing, Inc.
 ___
 es-discuss mailing list
 es-discuss@mozilla.org
 https://mail.mozilla.org/listinfo/es-discuss

___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: iterating through object property values

2014-12-03 Thread Caitlin Potter
 Have to be really careful adding things to Object.prototype, though — even 
 when they’re non-enumerable, they can cause unexpected problems in code (code 
 which probably ought to be using Object.create(null), but you know, doesn’t).


Being a Symbol rather than a String property key probably mitigates most of 
these problems, but I’m not positive about that.

Caitlin Potter

 On Dec 3, 2014, at 12:23 PM, Caitlin Potter caitpotte...@gmail.com wrote:
 
 It seems a bit late to add a default @@iterator to Object.prototype, but I 
 guess it could work similar to Map.prototype.entries, if such a thing were to 
 be added.
 
 Have to be really careful adding things to Object.prototype, though — even 
 when they’re non-enumerable, they can cause unexpected problems in code (code 
 which probably ought to be using Object.create(null), but you know, doesn’t).
 
 Caitlin Potter
 
 On Dec 3, 2014, at 12:07 PM, Mark Volkmann r.mark.volkm...@gmail.com wrote:
 
 It seems the typical way to do this is:
 
 Object.keys(myObj).forEach(key = {
  let value = myObj[key];
  // Do something with value and/or key.
 });
 
 I don't see a new way to do this in ES6.
 
 Is it still being considered to add the methods entries and values to 
 Object that return iterators?
 
 -- 
 R. Mark Volkmann
 Object Computing, Inc.
 ___
 es-discuss mailing list
 es-discuss@mozilla.org
 https://mail.mozilla.org/listinfo/es-discuss
 

___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: iterating through object property values

2014-12-03 Thread Allen Wirfs-Brock
for (key of Reflect.ownKeys(myObj)) {
  //Do something with key or myObj[key]
}

Allen


On Dec 3, 2014, at 9:07 AM, Mark Volkmann wrote:

 It seems the typical way to do this is:
 
 Object.keys(myObj).forEach(key = {
   let value = myObj[key];
   // Do something with value and/or key.
 });
 
 I don't see a new way to do this in ES6.
 
 Is it still being considered to add the methods entries and values to 
 Object that return iterators?
 
 -- 
 R. Mark Volkmann
 Object Computing, Inc.
 ___
 es-discuss mailing list
 es-discuss@mozilla.org
 https://mail.mozilla.org/listinfo/es-discuss

___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss