Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why enum is a reserved keyword in vanilla javascript?

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.

like image 210
Vencovsky Avatar asked Jan 25 '23 09:01

Vencovsky


1 Answers

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.

like image 123
Vencovsky Avatar answered Feb 07 '23 17:02

Vencovsky