Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Chrome 105
Mac OS X 10.15.7
Desktop
2 years ago
Test name Executions per second
Lodash 5650757.0 Ops/sec
Native 8009918.5 Ops/sec
HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>  
Script Preparation code:
x
 
function chunk(input, size) {
  
  const length= input.length;
  const chunksLenght= length/size;
  
  if(chunksLenght<0){
    return input;
  }
  
  const chunks=[];
  
  let index = 0;
  
  for(let i =0 ;i < chunksLenght ; i++){
    chunks.push(input.slice(index , index + size));
    index += size;
  }
  
  // the remainig 
  if(index < length){
     chunks.push(input.slice(index , length));
  }
  
  
  return chunks;
};
Tests:
  • Lodash

     
    _.chunk(['a', 'b', 'c'], 3);
  • Native

     
    chunk(['a', 'b', 'c'], 3);