This project is read-only.

How do i compare enum values from javascript?

Sep 19, 2012 at 5:22 AM

I have an object that is being passed into the context.  One of the properties of the object is an enum.  In javascript what is the proper way to do the comparison?


enum ExampleEnum {

Test1 = 1,

Test2 = 2



class ExampleObj {

ExampleEnum Example { get; set;}



in javascript

the things i've tried... both seem to have failed:

A: if(instance.Example == "Test1") DoSomething();

B: if(instance.Example == 1) DoSomething();


Sep 20, 2012 at 12:08 AM

Assuming you are using v0.7, the enum should be converted to a string (I think).  Therefore I would expect your A to work.  Try passing the enum back to C# again and then take a look at what you get.