Test name | Executions per second |
---|---|
rest with 10 args | 7593549.5 Ops/sec |
rest with 1 arg | 15670709.0 Ops/sec |
argsToArray with 10 args | 4001228.5 Ops/sec |
argsToArray with 1 arg | 8999644.0 Ops/sec |
function rest(args) {
return function(fn) {
return args.map(fn);
};
}
function argsToArray() {
const len = arguments.length;
const args = Array(len);
for (let i = 0; i < len; i++) {
args[i] = arguments[i];
}
return function(fn) {
return args.map(fn);
};
}
rest(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)(n => 2 * n);
rest(1)(n => 2 * n);
argsToArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)(n => 2 * n);
argsToArray(1)(n => 2 * n);