Created
April 23, 2020 04:55
-
-
Save Sprit3Dan/01dc4d892d9b97b7422cba7535c39f9f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| getEnum = function(values) { | |
| var obj = {}; | |
| values.forEach((v, iter) => { | |
| Object.defineProperty(obj, v, { | |
| enumerable: true, | |
| get() { | |
| return v | |
| } | |
| }); | |
| }); | |
| Object.freeze(obj) | |
| return obj; | |
| } | |
| const months = getEnum(["Jan", "Feb", "Mar"]) | |
| console.log(months); | |
| console.log(months.Jan); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment