String to number type coercion approaches

Benchmark created by Nathaniel Lee on


Setup

var str = '10000';
    var num;

Test runner

Ready to run.

Testing in
TestOps/sec
Number constructor
num = Number(str);
ready
Multiply by 1
num = str * 1;
ready
Unary plus
num = +str;
ready

Revisions

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

  • Revision 1: published by Nathaniel Lee on