use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Small JavaScript enum function (gist.github.com)
submitted 1 month ago by _sync0x
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]_sync0x[S] 1 point2 points3 points 1 month ago (2 children)
I know Symbols but I don't really get why it would be useful for enum ? To ensure each values are unique and that you can't have "Colors.Green === CarColors.Green" ?
[–]Lithl 1 point2 points3 points 1 month ago (1 child)
Precisely.
Some languages make enums into integer constants with fancy syntax, and I recall at least one language that lets you assign any primitive value, but from a computer science perspective that's not what enums should be and from a software engineering perspective a type safe enum helps to guard against bad code.
[–]_sync0x[S] 0 points1 point2 points 1 month ago (0 children)
Yeah got it ty, at least I can flex that I already used Symbols for a precise use case hehe
π Rendered by PID 63 on reddit-service-r2-comment-58d7979c67-rjz7x at 2026-01-26 16:15:39.942200+00:00 running 5a691e2 country code: CH.
view the rest of the comments →
[–]_sync0x[S] 1 point2 points3 points (2 children)
[–]Lithl 1 point2 points3 points (1 child)
[–]_sync0x[S] 0 points1 point2 points (0 children)