nison.mael at gmail.com
Tue Sep 6 20:07:12 UTC 2016
Previous thread (2 years ago) here:
It is still incredibly common to check if an object contains a key using:
if (Object.prototype.hasOwnProperty.call(myObject, key))
This syntax is quite verbose, and doesn't really make sense in the first
place. As someone said in the previous thread, hasOwnProperty should have
never been added to the Object prototype.
According to the discussion, Reflect.hasOwn has been thrown away in order
to keep the Reflect API simple, arguing that such a method could easily be
replaced by Reflect.getOwnPropertyDescriptor anyway. While this is
certainly true, the situation isn't without parallel with
Array.prototype.includes, which has been added as least in part in order to
help conveying a semantic meaning in the source code.
Since the usage hasn't decreased, what would you think about reconsidering
Reflect.hasOwn for adoption?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss