Retrieving key of a JavaScript object using its index in JQUERY - Javascript Object

Javascript examples for Object:Object Keys

Description

Retrieving key of a JavaScript object using its index in JQUERY

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-2.0.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/* www .j a v a 2 s  .c  om*/
var obj = {
    "set1": [1, 2, 3],
    "set2": [4, 5, 6, 7, 8],
    "set3": [9, 10, 11, 12]
};
var arr = []
for (var key in obj) {
    arr.push({key:obj[key]});
}
console.log(arr[1])
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials