Number.isNaN
Checks whether a value is the NaN number value.
Number helpers parse, validate and format numeric values. Some live on Number, others live on number instances.
Number.parseFloat("19.95px");
Number.isInteger(12);
(19.95).toFixed(2);
Strings, Numbers & Math
Number has static helpers such as Number.isNaN, Number.isFinite, Number.isInteger, Number.parseInt and Number.parseFloat.
Number values also have instance methods such as toFixed, toPrecision and toString. These are mostly used for display or conversion.
Parsing and formatting are different jobs. Parse data at the boundary. Calculate with numbers. Format only when showing the final value to the user.
Checks whether a value is the NaN number value.
Checks whether a value is a finite number without coercion.
Parse numeric text from the start of a string.
Returns a string with a fixed number of decimal places.
Examples
const raw = "19.95";
const value = Number.parseFloat(raw);
if (Number.isFinite(value)) {
console.log(value.toFixed(2));
}
const value = 19.95; const formatted = value.toFixed(2); console.log(formatted + 5); // "19.955"
Code patterns
These small examples are designed for scanning. Use them when you need the syntax quickly, then read the surrounding notes when you want the deeper reason behind the pattern.
Pass radix 10 for clear decimal parsing.
const page = Number.parseInt("12", 10);
console.log(page);
parseFloat reads a decimal number from the start.
const width = Number.parseFloat("42.5px");
console.log(width); // 42.5
toFixed returns a string for display.
const value = 19.9; const visible = value.toFixed(2); console.log(visible); // "19.90"
Use this when an exact integer id or count matters.
const id = 9007199254740992; console.log(Number.isSafeInteger(id)); // false
Rules that matter
Strings and numbers are simple until they cross a boundary: form input, API data, generated output, rounding, formatting or search. Normalize, validate and format deliberately.
Do not keep calculating with formatted output.
The Number version does not coerce before checking.
Convert input once, then pass numbers through the rest of the code.
It stops when parsing no longer fits a number.
It handles locale-aware formatting better than manual string work.
Do not format NaN as if it were a normal number.
Production thinking
Number helpers prevent messy data from leaking into calculations and help display numbers in a way users understand.
Formatted numeric text should be readable and not rely only on symbols or visual context.
Production systems should keep raw numeric values separate from formatted display strings.
Structured values and visible numeric content should not mix raw, rounded and formatted values inconsistently.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Explain the answer in plain language first. Then change the code example and verify that the result matches your explanation.