Javascript examples for Object:Object Property
Use parameter to define field name
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w . j a va2 s .c o m var n = 10 var collections = []; for(var i = 0; i < 10; i++){ var json1 = {}; var row = []; json1['color'] = '#000000'; json1['y'+i+'axis'] = {from: 1234}; row.push(json1); collections.push(row); } console.log(collections); } </script> </head> <body> </body> </html>