Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To concisely answer your question, everything beneath the <code>LeftHandSideExpression</code> production is a valid <code>LeftHandSideExpression</code>.</p> <hr> <p>I think the question you are really asking is:</p> <blockquote> <p>What is a valid <code>LeftHandSideExpression</code> and also assignable?</p> </blockquote> <p>The answer to that is anything that resolves to a <code>Reference</code> which is a well defined concept in the specification. In your example</p> <pre><code>new Object = 1; </code></pre> <p>The <code>new Object</code> is a valid <code>LeftHandSideExpression</code> but it does not resolve to a <code>Reference</code>.</p> <pre><code>(new Object).x = 1; </code></pre> <p>The left hand side is a <code>MemberExpression . IdentifierName</code> which according to the spec the final step is:</p> <blockquote> <p>Return a value of type Reference <strong>...</strong></p> </blockquote> <hr> <p>If you consider it 2 separate properties it makes a lot more sense.</p> <ol> <li>Is it a valid LeftHandSideExpression?</li> <li>Is it a valid reference? </li> </ol> <p>Property 1 is determined in the syntactical analysis phase and property 2 is determined in the semantic analysis phase. Check out <strong>8.7.2 PutValue (V, W)</strong> for more details.</p> <p>Here is a full explanation in the specification itself:</p> <p><strong>8.7 The Reference Specification Type</strong></p> <p>The Reference type is used to explain the behaviour of such operators as delete, typeof, and the assignment operators. For example, the left-hand operand of an assignment is expected to produce a reference. The behaviour of assignment could, instead, be explained entirely in terms of a case analysis on the syntactic form of the left-hand operand of an assignment operator, but for one difficulty: function calls are permitted to return references. This possibility is admitted purely for the sake of host objects. No built-in ECMAScript function defined by this specification returns a reference and there is no provision for a user-defined function to return a reference. (Another reason not to use a syntactic case analysis is that it would be lengthy and awkward, affecting many parts of the specification.)</p> <hr> <p>After taking a look at your suggestion I believe it would throw off certain valid expressions <em>(Note: I don't condone this.)</em></p> <pre><code>function OuterObj() { this.Name = "Outer"; this.InnerObj = function() { this.Name = "Inner"; } } var obj; (obj = new new OuterObj().InnerObj).Name = "Assigned"; </code></pre> <p>This is a case where <code>NewExpression</code> is important</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload