push value at index in nested array - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

push value at index in nested 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(){/* ww w.  j  av  a 2  s.  co m*/
var myArray = {};
myArray['1'] = [];
myArray['2'] = [];
myArray['3'] = [];
for(i=0; i<10; i++){
    myArray['1'].push(i);
    myArray['2'].push(i);
    myArray['3'].push(i);
}
console.log( JSON.stringify(myArray,null,4) ); // null,4 provides easy to read formating
    }

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

Related Tutorials