To simulate enums in JS, you can use an object


To simulate enums in JS, you can use an object. But I often prefer to use consts.

To me, consts read better, are easier to use, and I don't have to use hungarian notation to give the enum object a unique name.

Here's an example of both patterns.

#javascript

View original on X