PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 9, 2022

[FIXED] Why enum is a reserved keyword in vanilla javascript?

 July 09, 2022     javascript, keyword     No comments   

Issue

I was trying to declare a variable named enum but got Uncaught SyntaxError: Unexpected reserved word error.

I'm not using typescript, so why is enum a reserved keyword?

I was searching for it and realized that enum is a reserved keyword, but protected is also reserved and doesn't give me the error.

enter image description here

I also couldn't find what enum is used for or how it works in vanilla js.


Solution

According to the docs

The following are reserved as future keywords by the ECMAScript specification. They have no special functionality at present, but they might at some future time, so they cannot be used as identifiers.

And enum is always reserved keyword.



Answered By - Vencovsky
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing