Do we really need the [[HasOwnProperty]] internal method and hasOwn trap

David Bruant bruant.d at
Wed Nov 14 07:58:57 PST 2012

Le 14/11/2012 07:35, Brendan Eich a écrit :
> Also Tom's point about precision counts, independent of allocations. A 
> "hasOwn" test in the MOP should not call the same thing that 
> Object.getOwnPropertyDescriptor calls, if we can help it
I don't think it's possible. This thread started with the intention of 
having has/hasOwn consistent with [[GetOwnProperty]]. If has or hasOwn 
is distinguishable from gOPD in any way (different trap, flag argument, 
etc.), then, it reopens the door to have has/hasOwn inconsistent with 
gOPD. If it is chosen to enforce has/hasOwn into being consistent with 
gOPD, then I think gOPD should remain as it currently is.
In my experience, I've never needed to do the distinction or had a use 
case where it was relevant to have a specific has/hasOwn behavior.

hOP and the "in" operator can be seen as conveniences on top of 
Object.gOPD (and Object.getPrototypeOf). "in" would just be syntactic 
sugar. What I'm saying is historically untrue (since both hOP and 'in' 
predate Object.gOPD), but that's not an absurd way of thinking of the 
ES5 object model.


More information about the es-discuss mailing list