On Mon, Feb 19, 2018 at 1:50 PM, Sebastian Malton <sebast...@malton.name>
wrote:

> 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)) {
>         continue;
>     }
>     ....
> }
> ```
>

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
https://github.com/tc39/proposals )
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to