[[Invoke]] and implicit method calls

Jason Orendorff jason.orendorff at gmail.com
Fri Sep 20 10:19:44 PDT 2013


On Fri, Sep 20, 2013 at 8:50 AM, Tom Van Cutsem <tomvc.be at gmail.com> wrote:
> To make matters more concrete, consider the has() trap:
>
> "foo" in proxy // triggers has(target, "foo"), returns a boolean
>
> Strictly speaking, we could do without the has() trap and instead call the
> getOwnPropertyDescriptor() trap, and then test whether it returns a
> descriptor or undefined (+ climb the prototype if it returns undefined). But
> this interface potentially requires consing a property descriptor only for
> it to be tested against undefined. So the has() operation: a) allows more
> direct interception of the in-operator and b) with potentially less
> allocations.

OK, taking all that at face value, what's the justification for .hasOwn()?

a) allows more direct interception of Object.prototype.hasOwnProperty()
b) potentially less allocations each time someone calls .hasOwnProperty().

I think .hasOwn() should be removed.

> If you think about it, these very same arguments apply to the invoke() trap.

It's on the same spectrum, I agree.

-j


More information about the es-discuss mailing list