![]() |
VOOZH | about |
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:
SyntaxErrorCause 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.
A common cause is omitting the colon between a property name and its value.
const exampleObject = {
property1 "value1",
property2: "value2"
};
SyntaxError: Missing ':' after property idAdd the missing colon.
{ property1: 'value1', property2: 'value2' }
Another cause is incorrect formatting or syntax when defining properties in an object literal.
const exampleObject = {
property1 = "value1", // Using = instead of :
property2: "value2"
};
SyntaxError: Missing ':' after property idUse the correct syntax with a colon.
{ property1: 'value1', property2: 'value2' }
A property name followed by a colon but without a value can also cause syntax issues.
const exampleObject = {
property1:, // Missing value
property2: "value2"
};
SyntaxError: Unexpected token ','Provide a value for the property.
{ property1: 'value1', property2: 'value2' }