If not for-in then what?

Axel Rauschmayer axel at rauschma.de
Wed Mar 28 08:11:24 PDT 2012

On Mar 28, 2012, at 17:06 , John J Barton wrote:

> In another thread Allen says:
>    we infer from array behavior that for-in was intended to iterate over the data elements of an object and not the behavioral elements (eg methods).
> Similar comments have been implied around the discussion of enumerable properties. I personally have never seen any JS code that had this assumption. On the contrary, before Object.keys(), for-in was widely used as a half-baked meta-programming iterator.
> If for-in is not intended to iterate all properties of an object then what is?

Object.getOwnPropertyNames() together with a hand-written traversal of the prototype chain.

Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120328/58740e15/attachment.html>

More information about the es-discuss mailing list