typeof number vs unary plus (v9)

Revision 9 of this benchmark created by adsad on


Description

Typeof check when looking for number, vs unary +

Setup

var num = 42;
    var notNum = {};

Test runner

Ready to run.

Testing in
TestOps/sec
typeof
typeof num === 'number';
typeof notNum === 'number';
ready
unary +
num === +num;
notNum === +notNum;
ready
typeof with instanceOf
typeof num === 'number' || num instanceof Number;
typeof notNum === 'number' || notNum instanceof Number;
ready
unary + with instanceOf
num === +num || num instanceof Number;
notNum === +notNum || notNum instanceof Number;
ready

Revisions

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