I need to emulate enum type in Javascript and approach seems pretty straight forward:
var MyEnum = {Left = 1; Right = 2; Top = 4; Bottom = 8}
N
You just have to use the bitwise operators:
var myEnum = { left: 1, right: 2, top: 4, bottom: 8 } var myConfig = myEnum.left | myEnum.right; if (myConfig & myEnum.right) { // right flag is set }
More info: