isNaN 2

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var str = "abc def",
        nan = +str;
   
    function _isNaN(a) {
        return !(1 > a || 1 < a || 1 == a);
    };
    function _isNaN2(a) {
        a = +a;
        return !(1 > a || 1 < a || 1 == a);
    };
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
isNaN(nan)
var a = isNaN(nan);
pending…
number test nan
var a = !(1 > nan || 1 < nan || 1 == nan);
pending…
_isNaN(nan);
var a = _isNaN(nan);
pending…
isNaN(str)
var a = isNaN(str);
pending…
number test str
var a = !(1 > str || 1 < str || 1 == str);
pending…
_isNaN(str)
var a = _isNaN(str);
pending…
number test +str
var nan2 = +str;
var a = !(1 > nan2 || 1 < nan2 || 1 == nan2);
pending…
_isNaN2(nan);
var a = _isNaN2(nan);
pending…
_isNaN2(str);
var a = _isNaN2(str);
pending…
number test +nan
var nan2 = +nan;
var a = !(1 > nan2 || 1 < nan2 || 1 == nan2);
pending…
number test +str ===
var myStr = +str;
var a = !(1 > myStr || 1 < myStr || 1 === myStr);
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