best string to number handling NaN

Benchmark created on


Setup

var a = 'a';
var b = 1;
var c = '1';

Test runner

Ready to run.

Testing in
TestOps/sec
~~Number()
~~Number(a);
~~Number(b);
~~Number(c);
ready
Number() || 0
Number(a) || 0;
Number(b) || 0;
Number(c) || 0;
ready
+a || 0 (implicit)
+a || 0;
+b || 0;
+c || 0;
ready
parseInt() || 0
parseInt(a) || 0;
parseInt(b) || 0;
parseInt(c) || 0;
ready

Revisions

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