Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1067302 of SyntaxError: missing } after property list

  • Revision slug: Web/JavaScript/Reference/Errors/Missing_curly_after_property_list
  • Revision title: SyntaxError: missing } after property list
  • Revision id: 1067302
  • Created:
  • Creator: fscholz
  • Is current revision? Yes
  • Comment new page

Revision Content

{{jsSidebar("Errors")}}

Message

SyntaxError: missing } after property list

Error type

{{jsxref("SyntaxError")}}

What went wrong?

There is a mistake in the object initializer syntax somewhere. Might be in fact a missing curly bracket, but could also be a missing comma, for example. Also check if any closing curly brackets or parenthesis are in the correct order. Indenting or formatting the code a bit nicer might also help you to see through the jungle.

Examples

Forgotten comma

Oftentimes, there is a missing comma in your object initializer code:

var obj = { 
  a: 1, 
  b: { myProp: 2 }
  c: 3
};

Correct would be:

var obj = {
  a: 1,
  b: { myProp: 2 },
  c: 3
};

See also

Revision Source

<div>{{jsSidebar("Errors")}}</div>

<h2 id="Message">Message</h2>

<pre class="syntaxbox">
SyntaxError: missing } after property list
</pre>

<h2 id="Error_type">Error type</h2>

<p>{{jsxref("SyntaxError")}}</p>

<h2 id="What_went_wrong">What went wrong?</h2>

<p>There is a mistake in the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer">object initializer</a> syntax somewhere. Might be in fact a missing curly bracket, but could also be a missing comma, for example. Also check if any closing curly brackets or parenthesis are in the correct order. Indenting or formatting the code a bit nicer might also help you to see through the jungle.</p>

<h2 id="Examples">Examples</h2>

<h3 id="Invalid_cases">Forgotten comma</h3>

<p>Oftentimes, there is a missing comma in your object initializer code:</p>

<pre class="brush: js example-bad">
var obj = { 
  a: 1, 
  b: { myProp: 2 }
  c: 3
};
</pre>

<p>Correct would be:</p>

<pre class="brush: js example-good">
var obj = {
  a: 1,
  b: { myProp: 2 },
  c: 3
};
</pre>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer">Object initializer</a></li>
</ul>
Revert to this revision