toFixed vs Math

Benchmark created on


Setup

var f = 40.78432145;
    function toDecPoint(input, places) {
            var MULTIDIVID = Math.pow(10, places);
            return Math.round(input * MULTIDIVID) / MULTIDIVID;
          }

Test runner

Ready to run.

Testing in
TestOps/sec
toFixed
f.toFixed(4) * 1;
ready
Math
toDecPoint(f, 4);
ready

Revisions

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