parseInt vs unary plus number coercion

JavaScript performance comparison

Test case created

Info

parseInt in the first case has to receive the second parameter to set the base to decimal, otherwise 0 will be returned, due the fact he will try to parse an octal number.

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…

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