optional args

JavaScript performance comparison

Revision 2 of this test case created by ainthek

Info

Comparison of various "optional argument" implementations. Staring with trivial.

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
arguments[0] and void
function test() {
  var a = arguments[0] !== (void 0) ? arguments[0] : "foo";
}
//this is what will be generated by #traceur with es6 option
pending…
arguments[0] and undefined
function test() {
  var a = arguments[0] !== undefined ? arguments[0] : "foo";
}
// same with undefined (eliminating void evaluation)
pending…
ad-hoc
function test(a) {
  a != null || (a = "foo");
}
//ad-hoc impl., null & undefined treated as missing arg, "" as valid value
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment