Test case name | Result |
---|---|
let number = +'100' | |
let number = parseInt('100') | |
let str = "" + 100 | |
let str = String(100) | |
let number = Number("100") | |
let bool = !!1 | |
let bool = Boolean(1) | |
let str = new String(100) | |
let number = 100 | |
let number = new Number("100") |
Test name | Executions per second |
---|---|
let number = +'100' | 104677912.0 Ops/sec |
let number = parseInt('100') | 8546226.0 Ops/sec |
let str = "" + 100 | 102924360.0 Ops/sec |
let str = String(100) | 8193978.5 Ops/sec |
let number = Number("100") | 8638681.0 Ops/sec |
let bool = !!1 | 107816104.0 Ops/sec |
let bool = Boolean(1) | 8542353.0 Ops/sec |
let str = new String(100) | 8712519.0 Ops/sec |
let number = 100 | 105781600.0 Ops/sec |
let number = new Number("100") | 7142400.0 Ops/sec |