Is there a simple way to format numbers in JavaScript, similar to the formatting methods available in C# (or VB.NET) via ToString(\"format_provider\")
or
Yes, there is definitely a way to format numbers properly in javascript, for example:
var val=2489.8237
val.toFixed(3) //returns 2489.824 (round up)
val.toFixed(2) //returns 2489.82
val.toFixed(7) //returns 2489.8237000 (padding)
With the use of variablename.toFixed .
And there is another function toPrecision()
.
For more detail you also can visit
http://raovishal.blogspot.com/2012/01/number-format-in-javascript.html