Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
Chrome 90
Windows
Desktop
3 years ago
Test name Executions per second
Math.Min - Math.Max 2055.9 Ops/sec
Array.Sort 473.4 Ops/sec
Script Preparation code:
x
 
// Create an array of 100,000 numbers (0 - 99,999)
var arr = Array.from(Array(100000).keys());
// Knuth Shuffle Function
function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;
  while (0 !== currentIndex) {
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }
  return array;
}
// Randomize Order
shuffle(arr);
Tests:
  • Math.Min - Math.Max

     
    var max = Math.max(...arr);
    var min = Math.max(...arr);
  • Array.Sort

     
    arr = arr.sort(function(a, b) {
      return a - b;
    });
    var max = arr[arr.length];
    var min = arr[0];