Enum flags in JavaScript
enums, flags, javascript
Solution
In javascript you should be able to combine them as:
var left_right = MyEnum.Left | MyEnum.Right;
Then testing would be exactly as it is in your example of
if ( (left_right & MyEnum.Left) == MyEnum.Left) {...}
Problem
I need to emulate enum type in Javascript and approach seems pretty straight forward: ``` var MyEnum = {Left = 1; Right = 2; Top = 4; Bottom = 8} ``` Now, in C# I could combine those values like this: ``` MyEnum left_right = MyEnum.Left | MyEnum.Right ``` and then I can test if enum has certain value: ``` if (left_right & MyEnum.Left == MyEnum.Left) {...} ``` Can I do something like that in Javascript?