Number (with string integer) vs Unary + (with string integer) vs parseInt (with string integer) vs Number (with string float) vs Unary + (with string float) vs parseInt (with string float) vs Number (with integer) vs Unary + (with integer) vs parseInt (with integer) vs Number (with float) vs Unary + (with float) vs parseInt (with float) vs Number (with NaN) vs Unary + (with NaN) vs parseInt (with NaN)Fastest: Unary + (with NaN) (49.2x faster)
166,833,008 ops/sec
15,944,333 ops/sec
15,858,300 ops/sec
14,895,774 ops/sec
7,965,178 ops/sec
7,933,422 ops/sec
7,779,816 ops/sec
7,509,618 ops/sec
5,446,434 ops/sec
5,331,914 ops/sec
5,304,712 ops/sec
5,266,758 ops/sec
4,284,784 ops/sec
4,057,670 ops/sec
3,389,490 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Number (with string integer) | |
| Unary + (with string integer) | |
| parseInt (with string integer) | |
| Number (with string float) | |
| Unary + (with string float) | |
| parseInt (with string float) | |
| Number (with integer) | |
| Unary + (with integer) | |
| parseInt (with integer) | |
| Number (with float) | |
| Unary + (with float) | |
| parseInt (with float) | |
| Number (with NaN) | |
| Unary + (with NaN) | |
| parseInt (with NaN) |
| Test name | Executions per second |
|---|---|
| ✓ Number (with NaN) | 133,550,008 Ops/sec |
| Unary + (with NaN) | 128,934,136 Ops/sec |
| parseInt (with NaN) | 123,709,656 Ops/sec |
| Number (with integer) | 78,157,392 Ops/sec |
| Unary + (with float) | 76,626,736 Ops/sec |
| Number (with float) | 74,036,704 Ops/sec |
| Unary + (with integer) | 73,983,024 Ops/sec |
| Number (with string integer) | 63,153,728 Ops/sec |
| parseInt (with integer) | 58,755,068 Ops/sec |
| parseInt (with float) | 53,077,900 Ops/sec |
| Unary + (with string integer) | 43,665,928 Ops/sec |
| parseInt (with string integer) | 38,442,036 Ops/sec |
| parseInt (with string float) | 8,629,276 Ops/sec |
| Unary + (with string float) | 7,671,954 Ops/sec |
| Number (with string float) | 7,397,962 Ops/sec |