Skip to content

Instantly share code, notes, and snippets.

@iandesj
Created November 27, 2019 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iandesj/b3bc67318d0af7f7956dbc09100eb6fd to your computer and use it in GitHub Desktop.
Save iandesj/b3bc67318d0af7f7956dbc09100eb6fd to your computer and use it in GitHub Desktop.
Example of an Enum-esque construct in JS
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