The JavaScript exception “missing : after property id” occurs when objects are created using the object initializer syntax. A colon (:) separates keys and values for the object’s properties. Somehow, this colon is missing or misplaced.
SyntaxError: Invalid shorthand property initializer (V8-based) SyntaxError: missing : after property id (Firefox) SyntaxError: Unexpected token '='. Expected a ':' following the property name 'x'. (Safari) SyntaxError: Unexpected token '+'. Expected an identifier as property name. (Safari)
When creating objects with the syntax, object initializer a colon (:) separates keys and values for the object’s properties.
const obj = { propertyKey: 'value' };
Correct would be to use a colon, or to use square brackets to assign a new property after the object has been created already.
const obj = { propertyKey: 'value' };
// or alternatively
const obj = {};
obj['propertyKey'] = 'value';
Put the expression in brackets []:
const obj = { ['b'+'ar']: 'foo' };