Reflect.hasOwn

Domenic Denicola d at domenic.me
Wed Sep 28 23:02:45 UTC 2016


Reflect is a namespace that contains the proxy traps (it’s a bit of an unfortunate name), so we shouldn’t be adding things to it that are not part of the meta-object protocol.

A new namespace, or using Object, might be OK. I think that it will still be controversial, since this proposal is in support of an objects-as-maps programming style which has caused many problems in the past and should not be encouraged. See e.g. http://www.2ality.com/2012/11/proto-breaks-webapps.html.

If you are using objects-as-maps safely, you’d use Object.create(null), in which case the `in` operator works fine and there's no need for hasOwnProperty incantations.


More information about the es-discuss mailing list