Unlike Date or Array, the Math object in JavaScript is not a constructor (you never call new Math()). It is a built-in static object containing mathematical constants and functions for rounding, geometric calculations, and numerical transformations.
| Method | Behavior | Example | Result |
|---|---|---|---|
Math.round(x) | Standard rounding (Rounds to nearest integer; 0.5 rounds up) | Math.round(4.5) | 5 |
Math.floor(x) | Always rounds DOWN toward negative infinity | Math.floor(4.9) | 4 |
Math.ceil(x) | Always rounds UP toward positive infinity | Math.ceil(4.1) | 5 |
Math.trunc(x) | Simply strips the decimal fraction (truncates) | Math.trunc(-4.9) | -4 |
Math.abs(x): Absolute (Non-negative) ValueMath.min() and Math.max():Finds the lowest or highest value from a list of arguments:
Math.floor(7.9)?Math.ceil(2.1)?[12, 45, 9] using Math.max?Math.abs(-42) return?new Math()?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Working with Date Object | Random Numbers Example |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.