DEV Community

Discussion on: Enums in JavaScript

 
zhengmao profile image
mao.zheng

Because this will force you to use the enum object defined above. you can't just use string(number) literal to make a comparison. It keeps the consistency of the codes your wrote

Thread Thread
 
marcosmol204 profile image
Marcos Molina 👩🏽‍💻

Can you write an example ?
Using the enum, checking if a color is a valid color in the enum ?