parseInt vs coercion

Benchmark created by cushman on


Setup

objects = [{}, [], 5, 5.5, '5']

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt
objects.forEach(function (object) {
 parseInt(object) === object;
})
ready
coercion
objects.forEach(function (object) {
  (object | 0) === +object;
})
ready

Revisions

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