What is the most efficient way to get the highest and the lowest values in a Array
<p>is there something like PHP: <code>max()</code> in javascript?</p>

<p>lets say i have an array like this:</p>

<pre><code>[2, 3, 23, 2, 2345, 4, 86, 8, 231, 75]
</code></pre>

<p>and i want to return the highest and the lowest value in this array. What is the fastest way to do that?</p>

<p>i have tried:</p>

<pre><code>function madmax (arr) {
  var max = arr[0],
      min = arr[1]

  if (min &gt; max) {
      max = arr[1]
      min = arr[0]   
  }

  for (i=1;i&lt;=arr.length;i++){
     if( arr[i] &gt; max ) {
       max = arr[i]
     }else if( arr[i] &lt; min ) {
       min = arr[i]
     }
}

return max, min
}

madmax([123, 2, 345, 153, 5, 98, 456, 4323456, 1, 234, 19874, 238, 4])
</code></pre>

<p>Is there a simpler way retrieve the max and min value of a array? </p>
