This JavaScript exception variable is a reserved identifier occurs if the reserved keywords are used as identifiers.
Message:
SyntaxError: The use of a future reserved word for an identifier is invalid (Edge)
SyntaxError: “x” is a reserved identifier (Firefox)
SyntaxError: Unexpected reserved word (Chrome)
Error Type:
SyntaxError
What happened?
When Reserved keywords are used as identifiers they will throw error. enum is reserved in both strict and sloppy mode. while the following keywords are reserved in strict mode.
- implements
- package
- public
- interface
- private
- protected
- let
- static
Example 1: The package is an identifier in strict mode, So it will work fine here.
<script> var package = "This is GeeksForGeeks"; document.write(package); </script> |
Output:
This is GeeksForGeeks
Example 2: The enum is an identifier, So it will throw SyntaxError.
<script> var enum = "This is GeeksForGeeks"; document.write(enum); </script> |
Output:
SyntaxError: Unexpected reserved word
Recommended Posts:
- JavaScript SyntaxError - Identifier starts immediately after numeric literal
- JavaScript | Reserved Words
- JavaScript | this Identifier
- JavaScript SyntaxError: Unterminated string literal
- JavaScript SyntaxError - Invalid regular expression flag "x"
- JavaScript SyntaxError - Missing ) after argument list
- JavaScript SyntaxError - Missing ) after condition
- JavaScript SyntaxError - Missing ':' after property id
- JavaScript SyntaxError - Missing ; before statement
- JavaScript SyntaxError - Missing = in const declaration
- JavaScript SyntaxError - Missing ] after element list
- JavaScript SyntaxError - Missing formal parameter
- JavaScript SyntaxError - Missing name after . operator
- JavaScript SyntaxError - Missing variable name
- JavaScript SyntaxError - "use strict" not allowed in function with non-simple parameters
- JavaScript SyntaxError - JSON.parse: bad parsing
- JavaScript SyntaxError - Unexpected token
- JavaScript SyntaxError - A declaration in the head of a for-of loop can't have an initializer
- JavaScript SyntaxError - Applying the 'delete' operator to an unqualified name is deprecated
- JavaScript SyntaxError - Function statement requires a name
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


