Created
November 27, 2019 16:39
-
-
Save iandesj/b3bc67318d0af7f7956dbc09100eb6fd to your computer and use it in GitHub Desktop.
Example of an Enum-esque construct in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const enumValue = (name) => Object.freeze({toString: () => name}); | |
const Colors = Object.freeze({ | |
RED: enumValue("Colors.RED"), | |
BLUE: enumValue("Colors.BLUE"), | |
GREEN: enumValue("Colors.GREEN") | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment