Test name | Executions per second |
---|---|
Math.floor(N) | 0.9 Ops/sec |
(N | 0) | 1.7 Ops/sec |
parseInt(N) | 0.9 Ops/sec |
var len = 10000000
var nums = Array(len)
.fill()
.map(() => Math.random() * 10000)
for (let i = 0; i < len; i++) {
const result = Math.floor(nums[i])
}
for (let i = 0; i < len; i++) {
const result = nums[i] | 0
}
for (let i = 0; i < len; i++) {
const result = parseInt(nums[i])
}