title: Cast int to enum in javascript
body: <p>How do you efficiently cast an int to enum in javascript?</p>
  
  <p>Say I have this enum</p>
  
  <pre><code>enuTable = // Table enum
  {
      enuUnknown: 0,
      enuPerson: 1,
      enuItem: 2,
      enuSalary: 3,
      enuTax: 4,
      enuZip: 5,
      enuAddress: 6,
      enuLocation: 7,
      enuTasks: 8,
  
  };
  </code></pre>
  
  <p>In part of the code I get a return value from an AJAX call that is a number corresponding to one of the above tables.</p>
  
  <p>I can write a switch transforming the value, however is there a more efficient (briefer) way of casting an int to enum? One reason is, I don't want to constantly have to change the switch, in case I change the enum. I guess I could use an array with the enum names and construct an identifier to index into the enum, however again, I would need to change the array every time the enum is changed. I guess what I am looking for is a transparent method, that doesn't require beforehand knowledge of the enum.</p>