Test name | Executions per second |
---|---|
JS spread | 14017842.0 Ops/sec |
JS Concat | 5120028.0 Ops/sec |
Avoiding | 32496372.0 Ops/sec |
const arr1 = [ 1,2,3 ];
const arr2 = [ 4,5,6 ];
function sum(arr){ return arr.reduce((prev, curr) => prev + curr, 0); }
sum([arr1,arr2]);
const arr1 = [ 1,2,3 ];
const arr2 = [ 4,5,6 ];
function sum(arr){ return arr.reduce((prev, curr) => prev + curr, 0); }
sum(arr1.concat(arr2));
const arr1 = [ 1,2,3 ];
const arr2 = [ 4,5,6 ];
function sum(arr){ return arr.reduce((prev, curr) => prev + curr, 0); }
sum(arr1) + sum(arr2);