parseInt with int argument vs type checking

Benchmark created by alarikh on


Test runner

Ready to run.

Testing in
TestOps/sec
parseInt
var f = function(i) {
  return parseInt(i);
}
f(12345)
ready
type check
var f = function(i) {
  return typeof i === "number" ? i : parseInt(i);
}
f(12345)
ready

Revisions

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

  • Revision 1: published by alarikh on