JS TutorialLesson 25Free preview
JS Math
This lesson is part of JavaScript · All levels
Summary
Math objects are a collection of static properties and methods for mathematical purposes such as abstractions, roots, ranks, and random numbers. The method is used directly without creating an instance, for example Math.random() or Math.max(3, 9). Understanding the flooring, ceiling, round, truncation is important because each behaves differently on a negative decimal number.
Key points
- Round the nearest, floor down, ceiling up, truncate decimal
- Math.random() yields a random fraction >= 0 and < 1
- Math.max() and Math.min() look for the greatest/minimum value of some arguments
- Math.sqrt, Math.pow, Math.abs, and Math.PI are available as static properties
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.