Number Methods
Methods for working with numbers.
Examples
toFixed()
Rounding to specific decimal places.
let x = 9.656;
console.log(x.toFixed(0)); // 10
console.log(x.toFixed(2)); // 9.66toPrecision()
Formatting to a total number of digits.
let x = 9.656;
console.log(x.toPrecision(2)); // 9.7
console.log(x.toPrecision(4)); // 9.656Test Your Knowledge
JavaScript Quiz
No quiz available for this topic yet.