In JavaScript, numbers are a fundamental data type used to represent numeric values. They can be integers, decimals, or special numeric values.
| Type | Description |
|---|---|
| Integer | Whole numbers, positive or negative (e.g., 42, -7) |
| Floating Point | Decimal numbers (e.g., 3.14, -0.001) |
| Special Values | Infinity, -Infinity, NaN (Not a Number) |
All numbers in JavaScript are stored as 64-bit floating point values (IEEE 754 standard).

💡 Numeric Literals
You can write numbers directly in your code using digits, optionally with decimals or scientific notation:
100(integer)3.14(floating point)-0.5(negative decimal)2e3(scientific notation for 2000)
JavaScript supports basic arithmetic operations with numbers:
- Addition:
+ - Subtraction:
- - Multiplication:
* - Division:
/ - Modulus (remainder):
% - Exponentiation:
**
💡 Example Arithmetic
5 + 3 results in 8
10 / 4 results in 2.5
2 ** 3 results in 8 (2 to the power of 3)
⚠️ Precision Limitations
Due to floating point representation, some decimal calculations may produce unexpected results:
0.1 + 0.2 === 0.3 evaluates to false because it results in 0.30000000000000004
JavaScript provides the Number object with useful properties and methods:
Number.MAX_VALUE— largest representable numberNumber.MIN_VALUE— smallest positive numberNumber.isNaN(value)— checks if value is NaNNumber.isFinite(value)— checks if value is finite number
📌 Deep Dive: Basic Number Usage
const a = 10;
const b = 3.5;
const sum = a + b; // 13.5
const power = a ** 2; // 100
const isFiniteNum = Number.isFinite(sum); // true
const isNanCheck = Number.isNaN('hello'); // false
const nanValue = 0 / 0; // NaN
power = 100
isFiniteNum = true
isNanCheck = false
nanValue = NaN
💡 NaN and Infinity
NaN means "Not a Number" and results from invalid numeric operations.
Infinity and -Infinity represent values beyond the largest or smallest representable numbers.
| Constant | Description |
|---|---|
Number.NaN | Represents "Not a Number" |
Number.POSITIVE_INFINITY | Represents positive infinity |
Number.NEGATIVE_INFINITY | Represents negative infinity |
⚠️ Comparing NaN
NaN is unique: it is not equal to anything, even itself. Use Number.isNaN() to check for NaN.
Quick Knowledge Check
Test what you just learned
Question 1 of 2
Which of these is NOT a valid numeric literal in JavaScript?
Question 2 of 2
What does Number.isNaN(value) check?
Loading results...