typeof number vs unary plus (v10)

Revision 10 of this benchmark created by Foo on


Description

Typeof check when looking for number, vs unary +

Setup

var num = 42;
    var notNum = '42';

Test runner

Ready to run.

Testing in
TestOps/sec
typeof, success
typeof num === 'number';
 
ready
typeof, failure
typeof notNum === 'number';
ready
typeof with instanceOf, success
typeof num === 'number' || num instanceof Number;
 
ready
typeof with instanceOf, failure
typeof notNum === 'number' || notNum instanceof Number;
ready
unary +, success
+num === num;
ready
unary +, failure
+notNum === notNum;
ready
unary + with instanceof, success
num === +num || num instanceof Number;
 
ready
unary + with instanceof, failure
notNum === +notNum || notNum instanceof Number;
 
ready
isNaN, success
isNaN(num);
ready
isNaN, failure
isNaN(notNum);
ready

Revisions

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