Build arrays to show index number - Javascript Array

Javascript examples for Array:map

Description

Build arrays to show index number

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   www.j  a v  a  2  s .  co  m*/
 var myArray = [12, 24, 36, 48, 60, 15, 30],
     newArray = myArray.map(function (value, index) {
         return [index + 1, value];
     });
console.log(newArray);
    }

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

Related Tutorials