Question: How can I retrieve an enum member by value?
See original GitHub issueSay for example I have this enum:
var Members = new Enum({
  A: "a",
  B: "b"
});
I’d like to be able to do something like:
var member = Members.byValue('a');
Did I miss something in the documentation, or is this currently impossible?
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (3 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
Get int value from enum in C# - Stack Overflow
In the Questions class I have a get(int foo) function that returns a Questions object for that foo . Is there an easy...
Read more >Twenty C# Questions Explained, 15, How do I get the string ...
Twenty C# Questions Explained, 15, How do I get the string value of an enum · Key moments. View all · Key moments...
Read more >enum in Java - GeeksforGeeks
Enums are used when we know all possible values at compile time, such as choices on a menu, rounding modes, command-line flags, etc....
Read more >How To Use Enums in TypeScript - DigitalOcean
You can declare enum members to have string values with the following ... Get help and share knowledge in our Questions & Answers...
Read more >Enum Types - Java™ Tutorials
An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must...
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

What is the reason for not allowing strings as values? I see this as a pretty common use case. In my system, use strings as values so that they are human-readable in the database. This means that in addition to wanting to use strings as values, I’d also be looking for an option to have a constructor option that changes the behaviour of toString/toJSON to return the value rather than the key.
Try to do a pull request…