for own(...) loop (spin-off from Re:, hasOwnProperty(), and inheritance)

Brendan Eich brendan at
Tue Nov 8 12:49:47 PST 2011

The recommended practice when writing for-in loops in JS today is to write:

  for (i in o) {
    if (o.hasOwnProperty(i)) {

Although many JS developers do not follow the recommendation (out of ignorance or intentionally, doesn't matter).

Should provide sugar for the recommended pattern? To make it compose with declarations and destructuring in the for head, it should use a contextual keyword immediately after 'for':

  for own (i in o) {

This is a small thing but it might pay off in the long run.

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

More information about the es-discuss mailing list