Skip to content
Related Articles

Related Articles

JavaScript SyntaxError “variable” is a reserved identifier

Improve Article
Save Article
Like Article
  • Last Updated : 24 Jul, 2020

This JavaScript exception variable is a reserved identifier occurs if the reserved keywords are used as identifiers.


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:


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.

    var package = "This is GeeksForGeeks"; 


This is GeeksForGeeks

Example 2: The enum is an identifier, So it will throw SyntaxError.

    var enum = "This is GeeksForGeeks"; 


SyntaxError: Unexpected reserved word
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!