Mastery Points
0
Math Object in javascript
Context & Logic
The built‑in Math object provides constants (like Math.PI) and methods (like Math.random, Math.round, Math.floor, Math.ceil, Math.abs) for performing mathematical tasks. Unlike constructors, you don't use 'new Math()'; you call its methods directly on the Math object.
Example
Math.round(3.6); // 4
Math.floor(3.6); // 3
Math.ceil(3.1); // 4
Math.max(1, 5, 2); // 5
Math.min(1, 5, 2); // 1
// Random number between 0 and 9
const rand = Math.floor(Math.random() * 10);These helpers cover most common numeric tasks: rounding, min/max, and generating simple random integers.