Convert normal array into an object array - Javascript Array Operation

Javascript examples for Array Operation:Array of Object

Description

Convert normal array into an object 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">
    window.onload=function(){//from w  ww  . jav  a 2s . c o m
var number = ["12","93","46"];
var counter = ["2","4","8"];
var time = ["12:32PM","04:30PM","03:30AM"];

var abc =[];
number.forEach(function(item,index){
abc.push({
  name:number[index],
  counter:counter[index],
  time:time[index]
})
})
console.log(abc)
    }

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

Related Tutorials