"Operator precedence": yield and =; ?? and || #5365
Labels
Content:JS
JavaScript docs
help wanted
If you know something about this topic, we would love your help!
MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
@bakkot brought this to my attention: There are at least two inaccuracies in the JavaScript operator-precedence table.
yield
/yield *
have equal precedence with=
and the other assignment operators (AssignmentExpression). This is whyx = yield 1
is valid in a generator, whilex + yield 1
is invalid.||
and??
have equal precedence (ShortCircuitExpression). Their grammar is such that they are mutually exclusive—they cannot be used together without parentheses—but they nevertheless have equal precedence.As an aside, I also find puzzling the inclusion of
=
as an operator but the exclusion of=>
. Both tokens create expressions. And neither=
nor=>
are actually binary operators over two expressions (both their left sides are evaluated as variable bindings, not expressions).=
and=>
even have equal precedence in the spec (AssignmentExpression again). Calling=
but not=>
an operator seems arbitrary.MDN Content page report details
en-us/web/javascript/reference/operators/operator_precedence
The text was updated successfully, but these errors were encountered: