Number Methods
toFixed(n) gives a string with n decimals. Number.isInteger checks whole numbers. toLocaleString formats numbers for a region, for example with thousand separators or a currency.
Number.MAX_SAFE_INTEGER is the largest whole number JavaScript stores exactly. For bigger values use BigInt.
Example
const n = 1234567.891;
console.log(n.toFixed(1));
console.log(Number.isInteger(5), Number.isInteger(5.5));
console.log(n.toLocaleString("en-US"));
console.log((2500).toLocaleString("en-NG", { style: "currency", currency: "NGN" }));Exercise
Round to 2 decimal places.
(3.14159).(2)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.