var a = 0.2 + 0.4; console.log(a);
In most browser, we may have the value 0.600…0001. It is very anonying when we want to show a value with decimal point. There are a lot of methods to deal with it. We focus on
Math.round(a * 10) / 10
I believe that you will say method 1 has high performance. But how faster it has?
Please see the result here: http://jsperf.com/round-vs-tofix-parsefloat