To format float value in JavaScript, use toFixed(num) method. The num is the number of digits after a point. var someFloat = 4.652456; alert(someFloat.toFixed(2)); // will show "4.65" It’s analogue of number_format() function in PHP.
If you enjoy our post, feel free to subscribes to our rss feeds
