!isNaN, typeof === number (v3)

Revision 3 of this benchmark created on


Setup

var num = 5,
        notnum = '5';

Test runner

Ready to run.

Testing in
TestOps/sec
isNaN
if (!isNaN(num)) {
  console.log('hi');
}

if (!isNaN(notnum)) {
  console.log('hi');
}
ready
typeof
if (num && typeof num === 'number') {
  console.log('hi');
}

if (notnum && typeof notnum === 'number') {
  console.log('hi');
}
ready

Revisions

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