Return second value from multiple arrays via for loop - Javascript Array Operation

Javascript examples for Array Operation:Array Nest

Description

Return second value from multiple arrays via for loop

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(){//www. j  a  va  2 s. com
var arr = [
    ['2009', 100, 40, 80],
    ['2010', 170, 60, 120],
    ['2011', 60, 120, 50],
    ['2012', 130, 40, 80]
];
var newArr = [];
for (var x = 0; x < arr.length; x++){
  newArr.push(arr[x][1]);
}
console.log(newArr);
    }

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

Related Tutorials