Skip to content

Number

In one line

A number is a numeric value — JavaScript has one number type for both integers and floating-point values.

In simple words

JavaScript has a single number type that represents both integers (42) and floating-point values (3.14). Numbers are stored as IEEE 754 double-precision (64-bit) floating point.

This means integers up to 2^53 are exact, but very large integers and most decimal fractions cannot be represented precisely. For example, 0.1 + 0.2 equals 0.30000000000000004, not 0.3. For large integers, use BigInt.

Useful number methods include toFixed (format decimals), toString (convert to string), parseInt, and parseFloat. The Math object provides Math.floor, Math.round, Math.max, Math.random, and more.

Example

javascript
const price = 19.99;
const qty = 3;
console.log(price * qty);          // 59.97
console.log((0.1 + 0.2).toFixed(1)); // "0.3"
console.log(Math.floor(3.7));        // 3

Numbers support arithmetic, formatting, and Math methods.

Common confusions

  • Confused with: BigInt

    The difference: Number is a 64-bit float and loses precision above 2^53; BigInt can represent arbitrarily large integers exactly but cannot be used with Math methods.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary