Intent to Ship: Ergonomic Brand Checks

85 views
Skip to first unread message

Matthew Gaudet

unread,
May 10, 2021, 5:20:39 PMMay 10
to dev-pl...@mozilla.org
Ergonomic Brand Checks is a language feature to ease the check whether or not an object has a private value. Instead of having to write

```
hasPrivateX(o) {
  try {
    o.#x;
    return true;
  } catch {
    return false;
  }
}
```

you can write

```
hasPrivateX(o) { return #x in o; }
```

Which in addition to being more clear, is also safer in the presence of private getters that could throw.

Bug:

* Implement Ergonomic brand checks: https://bugzilla.mozilla.org/show_bug.cgi?id=1648090

Proposed Standard:

* https://tc39.es/proposal-private-fields-in-in/

Proposal Repository:

* https://github.com/tc39/proposal-private-fields-in-in

MDN:

* Not currently documented I believe.

Platform coverage:

* all platforms

DevTools Bug:

* https://bugzilla.mozilla.org/show_bug.cgi?id=1710516

Other Browsers:

* Shipped in Chrome 91.

Testing:

* Test262 Tests https://github.com/tc39/test262/pull/2963

Secure contexts:

* This is a JS language feature and is therefore present in all contexts.
Reply all
Reply to author
Forward
0 new messages