Open In App

JavaScript SyntaxError – Missing variable name

Last Updated : 22 May, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

This JavaScript exception missing variable name occurs frequently If the name is missing or the comma is wrongly placed. There may be a typing mistake.

Message:

SyntaxError: missing variable name (Firefox)
SyntaxError: Unexpected token = (Chrome)

Error Type:

SyntaxError

Cause of Error: There might be a variable missing a name. This is because of syntax errors in the code. The comma might be misplaced somewhere in the code.

Example 1: The variable name is missing, So the error has occurred.

Javascript




let = "This is GeeksforGeeks";


Output(In console):

SyntaxError: Unexpected token =

Example 2: The comma(, ) is used in place of “;”, So the error has occurred.

Javascript




let var1 = "This is ",
let var2 = "GFG";


Output(In console):

SyntaxError: Unexpected token 'var'

Previous Article
Next Article

Similar Reads

JavaScript SyntaxError - Missing name after . operator
This JavaScript exception missing name after . operator occurs if the dot operator (.) is used in the wrong manner for property access. Message: SyntaxError: missing name after . operator Error Type: SyntaxError Cause of Error: The dot operator (.) is used to access the property. Users will have to provide the name of the properties to access. Some
1 min read
JavaScript SyntaxError - Missing ) after argument list
This JavaScript exception missing ) after argument list occurs if there is an error in function calls. This could be a typing mistake, a missing operator, or an unescaped string. Message: SyntaxError: Expected ')' (Edge) SyntaxError: missing ) after argument list (Firefox) Error Type: SyntaxError Cause of Error: Somewhere in the code, there is an e
1 min read
JavaScript SyntaxError - Missing ) after condition
This JavaScript exception missing ) after condition occurs if there is something wrong with if condition. Parenthesis should be after the if keyword. Message: SyntaxError: Expected ')' (Edge) SyntaxError: missing ) after condition (Firefox) Error Type: SyntaxError Cause of Error: Somewhere in the code there is something wrong with if condition how
1 min read
JavaScript SyntaxError - Missing ':' after property id
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 (:) i
1 min read
JavaScript SyntaxError - Missing ; before statement
This JavaScript exception missing ; before statement occurs if there is a semicolon (;) missing in the script. Message: SyntaxError: Expected ';' (Edge) SyntaxError: missing ; before statement (Firefox) Error Type: SyntaxError Cause of Error: Somewhere in the code, there is a missing semicolon (;). You need to provide it so that JavaScript can pars
1 min read
JavaScript SyntaxError - Missing = in const declaration
This JavaScript exception missing = in const declaration occurs if a const is declared and value is not provided(like const ABC_DEF;). Need to provide the value in same statement (const ABC_DEF = '#ee0'). Message: SyntaxError: Const must be initialized (Edge) SyntaxError: missing = in const declaration (Firefox) SyntaxError: Missing initializer in
1 min read
JavaScript SyntaxError - Missing ] after element list
This JavaScript exception missing ] after element list occurs, It might be an error in array initialization syntax in code. Missing closing bracket (“]”) or a comma (“,”) also raises an error. Message: SyntaxError: missing ] after element list Error Type: SyntaxError Cause of Error: Somewhere in the script, there is an error with the array initiali
1 min read
JavaScript SyntaxError - Missing formal parameter
This JavaScript exception missing formal parameter occurs if any function declaration doesn't have the valid parameters. Message: SyntaxError: missing formal parameter (Firefox) Error Type: SyntaxError Cause of Error: The function declaration is missing the formal parameters. Example 1: In this example, the parameter 'num' is not defined in the lis
1 min read
JavaScript SyntaxError - Missing } after function body
This JavaScript exception missing } after function body occurs if there is any syntactic mistyping while creating a function somewhere in the code. Closing curly brackets/parentheses must be incorrect order. Message: SyntaxError: Expected '}' (Edge) SyntaxError: missing } after function body (Firefox) Error Type: SyntaxError Cause of Error: Somewhe
1 min read
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 com
1 min read