title: Finding the key of the max value in a javascript array
body: <p>I have an empty array into which I am pushing values using javascript. I am able to find the max value of the array and set that to a variable using the following:</p>
  
  <pre><code>Array.max = function( array ){
      return Math.max.apply( Math, array );
  };
  
  var maxX = Array.max(xArray);
  </code></pre>
  
  <p>How can I find the key associated with that value?</p>