You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Should parentheses limit the scope of short-circuting?
Parentheses limit the scope of short-circuting:
```js
(a?.b).c
(a ==null?undefined:a.b).c// this?
a ==null?undefined: (a.b).c// or that?
(a ==null?undefined:a.b).c
```
Given that parentheses are useless in that position, it should not have impact in day-to-day use.
Unless there is a strong reason for one way or the other, the answer will mostly depend on how the feature is specified.
That follows from the design choice of specifying the scope of short-circuiting by syntax (like the `&&` operator), rather than propagation of a Completion (like the `break` instruction) or an adhoc Reference (like an [earlier version of this proposal](https://github.com/claudepache/es-optional-chaining)). In general, syntax cannot be arbitrarly split by parentheses: for example, `({x}) = y` is not destructuring assignment, but attempt to assign a value to an object literal.
Note that, whatever the semantics is, there is no practical reason to use parentheses in that position anyway.