Own isNaN vs. underscore/lodash isNaN

JavaScript performance comparison

Test case created by marksyzm

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  function definitelyNaN (val) {
      if (val !== val) {
          return true;
      }
      return isNaN(val && val !== true ? Number(val) : parseFloat(val));
  }

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
definitelyNaN
definitelyNaN(NaN);
definitelyNaN(0);
definitelyNaN(1);
definitelyNaN(1.23456789);
definitelyNaN(0x00025);
definitelyNaN("0");
definitelyNaN("1");
definitelyNaN("1.23456789");
definitelyNaN("0x00025");
definitelyNaN("1.2geoff");
definitelyNaN(".2geoff");
definitelyNaN("geoff");
pending…
_.isNaN
_.isNaN(NaN);
_.isNaN(0);
_.isNaN(1);
_.isNaN(1.23456789);
_.isNaN(0x00025);
_.isNaN("0");
_.isNaN("1");
_.isNaN("1.23456789");
_.isNaN("0x00025");
_.isNaN("1.2geoff");
_.isNaN(".2geoff");
_.isNaN("geoff");
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.

0 Comments