typeof number vs unary plus (v4)

Revision 4 of this benchmark created on


Description

Typeof check when looking for number, vs unary +

Setup

var toCheck = 42;
    var a = 0;
    
    var numString = 'number';

Test runner

Ready to run.

Testing in
TestOps/sec
typeof
if (typeof numString === 'number') {
 a++;
}
ready
typeof cached comparison
if (typeof numString === numString) {
 a++;
}
ready
unary +
if (numString === +numString) {
 a++;
}
ready
|0
if(numString === numString|0) {
  a++;
}
ready
number
if(numString === Number(numString)) {
  a++;
}
ready

Revisions

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