Open In App

JavaScript SyntaxError - Unexpected token

Last Updated : 31 Jul, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

This JavaScript exceptions unexpected token occur if a specific language construct was expected, but anything else is typed mistakenly. This could be a simple typing mistake.

Message:

SyntaxError: expected expression, got "x"
SyntaxError: expected property name, got "x" 
SyntaxError: expected target, got "x"
SyntaxError: expected rest argument name, got "x"
SyntaxError: expected closing parenthesis, got "x"
SyntaxError: expected '=>' after argument list, got "x"

Error Type:

SyntaxError

Cause of Error: There is a simple typing mistake in the code.

Example 1:

Output:

01234

Example 2: There is a typing mistake in the code, So the error occurred.

Output(in console):

SyntaxError: Unexpected token ';'

Next Article

Similar Reads