Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Compare the ways to convert String to Number in JS +
Compare the most popular ways to convert string to number
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser:
Firefox 139
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
+
174/s
>>0
174/s
~~
167/s
*1
166/s
|
127/s
parseInt
126/s
Number
83/s
View exact numbers
Test name
Executions per second
✓
+
174 Ops/sec
>>0
174 Ops/sec
~~
167 Ops/sec
*1
166 Ops/sec
|
127 Ops/sec
parseInt
126 Ops/sec
Number
83 Ops/sec
Script Preparation code:
const minimum = 1 const maximum = 1000 var arr = Array.from({ length: 1000000 }, () => Math.floor(Math.random() * (maximum - minimum + 1)) + minimum)
Tests:
Number
return arr.map((el) => Number(el))
parseInt
return arr.map((el) => parseInt(el))
>>0
return arr.map((el) => el >> 0)
*1
return arr.map((el) => el * 1)
~~
return arr.map((el) => ~~el)
+
return arr.map((el) => +el)
|
return arr.map((el) => el|0)