Skip to main content Accessibility Feedback

Numbers

Number.toFixed()

Format a number to a fixed number of decimal places. Pass in the number of decimal places as an argument.

var pi = 3.14159;
var eleven = 11;

// returns 3.14
pi.toFixed(2);

// returns 11.000
eleven.toFixed(3);

Works back to at least IE6.