Wednesday, September 25, 2024
Google search engine
HomeLanguagesJavascriptJavaScript SyntaxError – Missing } after property list

JavaScript SyntaxError – Missing } after property list

This JavaScript exception missing } after property list occurs if there is a missing comma, or curly bracket in the object initializer syntax.

Message:

SyntaxError: Expected '}' (Edge)
SyntaxError: missing } after property list (Firefox)

Error Type:

SyntaxError

Cause of Error: Somewhere in the script, there is a missing curly bracket or missing comma in the object initializer syntax.

Example 1: In this example, there is a missing comma, So the error has occurred.

Javascript




let GFG_Obj = {
    prop1: 1,
    // Missing "," here
    prop2: { prop21: 2 }
prop3: 3
};
console.log(GFG_Obj);


Output(In console):

SyntaxError: Expected '}'

Example 2: In this example, there is a missing curly bracket, So the error has occurred.

Javascript




let GFG_Obj = {
    prop1: 1,
    // Missing "}" here
    prop2: {
        prop21: 2,
        prop3: 3
    };
console.log(GFG_Obj);


Output(In console): 

SyntaxError: Expected '}'
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments