Find minimum in array of arrays - Javascript Array

Javascript examples for Array:map

Description

Find minimum in array of arrays

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 v  a  2  s.c  o m*/
var arr = [
  [1117151200000, 376.2],
  [1117137600000, 350],
  [1117124000000, 374.5]
]
var numbs     = arr.map(function(x) { return x[1]||0 });
var timestamp = arr[numbs.indexOf(Math.min.apply( Math, numbs ))][0];
console.log(timestamp)
    }

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

Related Tutorials