[Webkit-unassigned] [Bug 226291] New: Implement Object.hasOwn

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed May 26 14:15:32 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=226291

            Bug ID: 226291
           Summary: Implement Object.hasOwn
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: me at thejameskyle.com

`Object.hasOwn` is a Stage 3 TC39 Proposal:

Proposal: https://github.com/tc39/proposal-accessible-object-hasownproperty
Spec: https://tc39.es/proposal-accessible-object-hasownproperty/

```
// Before:
({ foo: true }).hasOwnProperty("foo")
// After:
Object.hasOwn({ foo: true }, "foo")
```

`Object.hasOwn` can likely be implemented with much of the same code as `Object.prototype.hasOwnProperty`

However, note that the steps of these functions are flipped:

> Object.prototype.hasOwnProperty ( _V_ )
> 
>     1. Let _P_ be ? ToPropertyKey(_V_).
>     2. Let _O_ be ? ToObject(*this* value).
>     ...
> 
> Object.hasOwn ( _O_, _P_ )
> 
>     1. Let _obj_ be ? ToObject(_O_).
>     2. Let _key_ be ? ToPropertyKey(_P_).
>     ...

I also looked for some relevant JavaScriptCore source code:

- `JSObject#hasOwnProperty`: https://github.com/WebKit/WebKit/blob/e40702b9a8a6ff87d4e9c4edd80b8e07090b3540/Source/JavaScriptCore/runtime/JSObject.h#L662-L664
- `JSObjectConstructor`: https://github.com/WebKit/WebKit/blob/800d33d28d0b267466a3f6daec5fa5056e72348d/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210526/7615fc07/attachment-0001.htm>


More information about the webkit-unassigned mailing list