Why is object with duplicated property accepted in JavaScript?
<p>I was expecting JavaScript to reject objects with duplicated properties as invalid but it accepts them in some cases.</p>

<p><code>{"a":4,"a":5}</code> results in an <code>SyntaxError</code> at least in Firefox and Chrome which seems obvious due to the property <code>a</code> being defined twice.</p>

<p>However <code>({"a":4,"a":5})</code> evaluates just fine and results in an object <code>{"a":5}</code> in both Firefox and Chrome.</p>

<p>Why is the expression with the parenthesis accepted?</p>

<p><strong>Summing up the responses:</strong> The first example is simply not the construction of an object but a block of labeled statements. Duplicated properities in objects are perfectly valid in which case the last definition wins.</p>

<p>Thanks a lot for your answers!</p>
