Skip to content
AgileLogics
3 min read

Numbers

Prerequisites: Data types

JavaScript has only one numeric type, number, used for both whole numbers and decimals — there's no separate int/float distinction like Python or PHP.

const whole = 42;
const decimal = 3.14;
const big = 42_000_000; // underscores as visual separators

Common mistakes

  • Expecting decimal math to be perfectly exact — 0.1 + 0.2 gives 0.30000000000000004 due to how decimals are stored in binary. This is true of nearly every programming language, not a JavaScript bug.