isNumber

JavaScript performance comparison

Test case created by dipser

Preparation code

<script>
  var input = 0; // false, 0, 1, '0', '1', 'str'
</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
typeof
(typeof + input === 'number' && input !== false) ? 'true' : 'false';
pending…
isNaN
(!isNaN(input) && input !== false) ? 'true' : 'false';
pending…
isNaN+parseFloat
!isNaN(parseFloat(input)) ? 'true' : 'false';
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