parseInt vs unary plus vs Number() vs double bitwise number coercion

JavaScript performance comparison

Revision 3 of this test case created by Phil Booth

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
parseInt 1
parseInt("09", 10)
pending…
unary plus 1
+"09"
pending…
parseInt 2
parseInt("10")
pending…
unary plus 2
+"10"
pending…
Number constructor 1
Number("09")
pending…
Number constructor 2
Number("10")
pending…
double bitwise 1
~~"09"
pending…
double bitwise 2
~~"10"
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