Convert Array to Custom Object - Javascript Array Operation

Javascript examples for Array Operation:Array Convert

Description

Convert Array to Custom Object

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  w w. j av  a 2 s .co m
var dataSeries = {};
dataSeries.data = [10,20,40,40,20];
var myjs = dataSeries.data.map(function(x) {
    return { data: x };
});
console.log(JSON.stringify(myjs));
    }

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

Related Tutorials