For-has-in loop

# Sebastian Malton (a month ago)

An HTML attachment was scrubbed... URL: esdiscuss/attachments/20180219/20addd75/attachment

# Peter Jaszkowiak (a month ago)

You could use Object.keys, Object.entries, or Object.values on the right side of of instead.

# Isiah Meadows (a month ago)

And I find it kind of absurd that engines don't yet optimize away the intermediate array allocation (even though it's literally almost equal to for ... in in performance).

Isiah Meadows me at

Looking for web consulting? Or a new website? Send me an email and we can get started.

# Mike Samuel (a month ago)

On Mon, Feb 19, 2018 at 1:50 PM, Sebastian Malton <sebastian at>


I would like to propose that the following be valid since it is a very common use case.

for (const field has in object) {

Would be equivalent to:

for (const field in object) {
    if (!object.hasOwnPropety(field)) {

I'm generally supportive of getting rid of error-prone calls to hasOwnProperty methods since they fail when there is a "hasOwnProperty" field anywhere on the prototype chain between object and Object.prototype.

This idiom looks like something that usually almost means what its author intends but rarely exactly.

Are there any proposals for an in operator variant that only checks for own properties? If so, the syntax could be synchronized with that. (I thought there was one but couldn't find it on tc39/proposals )