Extract the property values of a JavaScript object into an array - Javascript jQuery

Javascript examples for jQuery:Array

Description

Extract the property values of a JavaScript object into an array

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-1.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*  w w  w .  ja va  2 s . co  m*/
var dataObject = {
   object1: {id: 1, name: "A"},
   object2: {id: 2, name: "B"},
   object3: {id: 3, name: "C"}
};
var arr = $.map(dataObject,function(v){
 return v;
});
console.log(arr);
    });

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

Related Tutorials