JS Coding Questions Logo
JS Coding Questions
#279💼 Interview💻 Code

Are enums available in javascript

Advertisement

728x90

No, javascript does not natively support enums. But there are different kinds of solutions to simulate them even though they may not provide exact equivalents. For example, you can use freeze or seal on object,

javascript
1var DaysEnum = Object.freeze({"monday":1, "tuesday":2, "wednesday":3, ...})

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 22

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
279of476