jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Comparison of ways to get the last argument to a function
const lastArgRest = (...args) => args[args.length - 1];
const lastArgConst = function() {
return arguments[arguments.length - 1];
};
const lastArgConstStrict = function() {
"use strict";
return arguments[arguments.length - 1];
};
function lastArgDecl() {
return arguments[arguments.length - 1];
}
function lastArgDeclStrict() {
"use strict";
return arguments[arguments.length - 1];
}
const lastArgRestConst = function(...args) {
return args[args.length - 1];
};
function lastArgRestDecl(...args) {
return args[args.length - 1];
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Rest Args |
| ready |
Const Function Arguments |
| ready |
Const Function Arguments - Strict |
| ready |
Declare Function Arguments |
| ready |
Declare Function Arguments - Strict |
| ready |
Const Function Rest Args |
| ready |
Declare Function Rest Args |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.