Created
August 17, 2017 15:24
-
-
Save thephilip/83c7003e7285a4a40d09c1910acff7ab to your computer and use it in GitHub Desktop.
Enumerated types in JavaScript
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
// create enumerated types in JavaScript | |
const EnumState; | |
(EnumState => { // ES6 IIFE!? No-ice | |
EnumState[EnumState["new"] = 1] = "new" | |
EnumState[EnumState["active"] = 2] = "active" | |
EnumState[EnumState["inactive"] = 3] = "inactive" | |
EnumState[EnumState["done"] = 4] = "done" | |
EnumState[EnumState["deleted"] = 5] = "deleted" | |
})( EnumState || ( EnumState = {} ) ); | |
/* | |
EnumState { | |
1: "new", 2: "active", 3: "inactive", 4: "done", 5: "deleted", | |
new: 1, active: 2, inactive: 3, done: 4, deleted: 5 | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment