Javascript examples for Array Operation:Array Convert
Convert Array to Custom Object
<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>