Number

JavaScript performance comparison

Test case created by CvX

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let i = 0.1;
  let array = [];
  
  while (i < 50000) {
    array.push(i.toString());
    array.push(i + 1.0);
    i += 2.0;
  }
  

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Number
array.map(i => Number(i))
pending…
parseFloat
array.map(i => parseFloat(i))
pending…
typeof Number
array.map(i => typeof i === 'number' ? i : Number(i))
pending…
typeof parseFloat
array.map(i => typeof i === 'number' ? i : parseFloat(i))
pending…

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

Compare results of other browsers

0 Comments