undefined vs. arguments.length

Benchmark created by Tom Doan on


Description

Comparing two methods to check whether a parameter is passed.

Test runner

Ready to run.

Testing in
TestOps/sec
undefined
function test1(arg) {
 if (arg == undefined) return;
}
test1();
ready
arguments.length
function test2(arg) {
 if (arguments.length == 0) return;
}
test2();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Tom Doan on