title: Getting minimum value of an array using Math.min.apply() in Javascript returns NaN?
body: <pre><code>var array1 = [4,2];
  var array2 = [1,3];
  
  var concatArray = array1.concat(array2);
  
  // iteration 1
  concatArray_min = Math.min.apply(Math,concatArray);
  var result = [concatArray_min];
  var index = concatArray.indexOf(concatArray_min);
  delete concatArray[index];
  console.log(concatArray);    // returns [4,2,3]
  console.log(result);         // returns [1]
  
  // iteration 2
  concatArray_min = Math.min.apply(Math,concatArray);
  console.log(concatArray_min);   // returns NaN
  result.push(concatArray_min);
  index = concatArray.indexOf(concatArray_min);
  delete concatArray[index];
  console.log(concatArray);    // returns [4,2,3]
  console.log(result);         // returns [1,NaN]
  </code></pre>
  
  <p>I am trying to merge two arrays and then sort them. I first concatenate the arrays and then delete the minimum from the unsorted concatenated array and push the minimum into the resulting array. This works at first, but fails for the second iteration as <code>concatArray_min</code> shows to be <code>NaN</code>. Perhaps the problem is in using <code>Math.min.apply.(Math,concatArray)</code> to get the minimum value and using <code>delete</code> to delete the element? Is there an alternative to this approach <strong>without using .sort()</strong>?</p>