parseInt && isInteger vs Regex

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
parseInt && isInteger
const isDecimal = (val) => Number.isInteger(parseInt(val, 10))

isDecimal('foo')
isDecimal('100.00.00')
isDecimal('100.00')
isDecimal('100')
ready
Regex
const isDecimal = (val) => /^\d+(\.\d+)?$/.test(val)

isDecimal('foo')
isDecimal('100.00.00')
isDecimal('100.00')
isDecimal('100')
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.