Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Windows
Desktop
5 years ago
Test name Executions per second
_.max 6410.8 Ops/sec
Math.max 12373.7 Ops/sec
HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js'></script>
Script Preparation code:
 
function getRandomInt(max) {
  return Math.floor(Math.random() * Math.floor(max));
}
var arr = [];
for(var i = 0; i < 1000; i++){
  arr.push({value:getRandomInt(100)});
}
Tests:
  • _.max

     
    _.max(arr);
  • Math.max

     
    Math.max(...arr)