This came out from Issue with "Expressions and operators": What _are_ left-hand-side expressions? · Issue #6586 · mdn/content · GitHub. MDN's categorization of expressions (in the expressions reference) follows the spec's, the latter of which defines a group called "Left-Hand-Side Expressions". This includes call expressions, new expressions, property accessors, import calls, etc. However, of all these, only property accessors actually evaluate to a reference and can be the left hand side of an assignment. I wonder, therefore, what "left-hand-side expressions" actually means in the spec, or if it's just because each production "happens to include" property accessors.
LeftHandSideExpression is the 'smallest' nonterminal that includes everything that can validly be on the left of an assignment. However, it also includes lots of things that can't be on the left of an assignment. Conceivably the grammar could be rearranged to make LeftHandSideExpression 'tighter' (include fewer invalid things), but I think the overall result would be worse.
Thanks, that makes sense. Put inside the spec's context it makes much more sense, because LHSE derives everything that people regard as "property accessors". Out of curiosity, what would you give as a name for the MDN category, considering usually when we say "optional chain expression", we mean the expression contains at least one ?.
, in which case it's not an LHS anymore?