Last Updated : 15 Jul, 2025
This JavaScript exception missing : after property id occurs if objects are declared using the object's initialization syntax.
Message:
SyntaxError: Expected ':' (Edge)
SyntaxError: missing : after property id (Firefox)
Error Type:
SyntaxError
Cause of Error: Somewhere in the code, Objects are created with object initializer syntax, and colon (:) is used to separate keys and values for the object's properties, Which is not used so.
Case 1: Missing Colon in Object Literal Error Cause:A common cause is omitting the colon between a property name and its value.
Example:const exampleObject = {Output:
property1 "value1",
property2: "value2"
};
SyntaxError: Missing ':' after property idResolution of Error:
Add the missing colon.
JavaScript
const exampleObject = {
property1: "value1", // Correct usage
property2: "value2"
};
console.log(exampleObject);
{ property1: 'value1', property2: 'value2' }Case 2: Incorrect Property Definition Error Cause:
Another cause is incorrect formatting or syntax when defining properties in an object literal.
Example:const exampleObject = {Output:
property1 = "value1", // Using = instead of :
property2: "value2"
};
SyntaxError: Missing ':' after property idResolution of Error:
Use the correct syntax with a colon.
JavaScript
const exampleObject = {
property1: "value1", // Correct usage
property2: "value2"
};
console.log(exampleObject);
{ property1: 'value1', property2: 'value2' }Case 3: Missing Value After Colon Error Cause:
A property name followed by a colon but without a value can also cause syntax issues.
Example:const exampleObject = {Output:
property1:, // Missing value
property2: "value2"
};
SyntaxError: Unexpected token ','Resolution of Error:
Provide a value for the property.
JavaScript
const exampleObject = {
property1: "value1", // Correct usage
property2: "value2"
};
console.log(exampleObject);
{ property1: 'value1', property2: 'value2' }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4