Can you attach some example :)?
it's just like this:
const Color = Object.freeze({ RED : Symbol("red"), BLUE : Symbol("blue"), GREEN: Symbol("green") });
Why do you prefer? Could you explain ?
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
Can you write an example ? Using the enum, checking if a color is a valid color in the enum ?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Can you attach some example :)?
it's just like this:
Why do you prefer? Could you explain ?
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
Can you write an example ?
Using the enum, checking if a color is a valid color in the enum ?