JavaScript SyntaxError - Unexpected token Last Updated : 31 Jul, 2020 Summarize Comments Improve Suggest changes Share 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: HTML <!DOCTYPE html> <html> <head> <title>Unexpected Token Error</title> </head> <body> <script> for (let i = 0; i < 5; ++i) { document.write(i); } </script> </body> </html> Output: 01234 Example 2: There is a typing mistake in the code, So the error occurred. HTML <!DOCTYPE html> <html> <head> <title>Unexpected Token Error</title> </head> <body> <script> for (let i = 0; i < 5,; ++i) { document.write(i); } </script> </body> </html> Output(in console): SyntaxError: Unexpected token ';' Comment More infoAdvertise with us Next Article JavaScript SyntaxError â Unexpected reserved word P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies javascript-basics Similar Reads JavaScript SyntaxError - Unexpected string The occurrence of a âSyntaxError: Unexpected stringâ in JavaScript happens when a programmer uses string data type in an expression, statement, or declaration where it is not appropriate, this syntax error stops the script and it may happen due to incorrect placement of strings in expressions, varia 2 min read JavaScript SyntaxError - Unexpected number The Unexpected number error in JavaScript occurs when the JavaScript engine encounters a number in a place where it isn't syntactically valid. This error is categorized as a SyntaxError, indicating that there's a problem with the structure of your code.MessageSyntaxError: Unexpected numberError Type 3 min read JavaScript SyntaxError â Unexpected template string A JavaScript error, âSyntaxError: Unexpected template stringâ, is raised when a template string ( ``) is misused or misplaced, although these strings permit the use of embedded expressions and multi-line strings, using them wrongly would cause the syntax to break, letâs get to know what this error i 2 min read JavaScript SyntaxError â Unexpected end of input A SyntaxError: Unexpected end of input error in JavaScript occurs when the interpreter reaches the end of script it is reading and it indicates that the code is incomplete, this error will prevent the code from running and mostly happens when a closing bracket, quote or parenthesis are missing, here 3 min read JavaScript SyntaxError â Unexpected reserved word A "SyntaxError: Unexpected reserved word" error in JavaScript is when a reserved word is used incorrectly, generally in a different identifier kind of context, this error will not allow the code to run and frequently results from using keywords as variable names, function names or by putting them at 3 min read JavaScript Error Handling: Unexpected Token Like other programming languages, JavaScript has define some proper programming rules. Not follow them throws an error.An unexpected token occurs if JavaScript code has a missing or extra character { like, ) + - var if-else var etc}. Unexpected token is similar to syntax error but more specific.Semi 3 min read Like