Javascript examples for Array Operation:Array of Object
Write object to array in function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// ww w. j ava 2 s. com var obj = { name : 'Tim', age : 20, hasPets : false }; console.log(arrayToObject(obj)); function arrayToObject(obj) { var result = Object.keys(obj).map(function(item){ return obj[item]; }); return result; }; } </script> </head> <body> </body> </html>