Number vs. plus vs. parseInt vs. parseFloat vs. /1 vs. *1 vs. 0+ vs. 1*

JavaScript performance comparison

Revision 20 of this test case created

Preparation code

<script>
  var num = '1234567890';
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Number
Number(num);
pending…
parseInt
parseInt(num, 10);
pending…
parseFloat
parseFloat(num);
pending…
parseInt (no extra parameter)
parseInt(num);
pending…
divide by 1
num / 1;
pending…
multiply by 1
num * 1;
pending…
1*
1 * num;
pending…
-0
num - 0
pending…
Bitwise not (~~1)
~~num
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment