_.isNumber vs typeof number

Benchmark created on


Preparation HTML

<script src=""https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>

Setup

const numbers = Array(1).fill(null).map(() => Math.random())

Test runner

Ready to run.

Testing in
TestOps/sec
isNumber
for (const number of numbers) {
	console.log(_.isNumber(number))
}
ready
typeof number
for (const number of numbers) {
	console.log(typeof number === 'number')
}
ready

Revisions

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