Populate an array with Enum variable - Javascript jQuery

Javascript examples for jQuery:Array

Description

Populate an array with Enum variable

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-compat-git.js"></script> 
  <script type="text/javascript">
    $(window).on('load', function() {
var myEnum = {//from   ww  w .  ja  v a 2 s .  c  om
first: 1,
second: 2,
third: 3
};
var enumsObj = [];
for(var prop in myEnum){
    enumsObj.push({id: myEnum[prop], name: prop})
}
$("#a").text(JSON.stringify(enumsObj))
    });

      </script> 
 </head> 
 <body> 
  <div id="a"></div>  
 </body>
</html>

Related Tutorials