Member-only story
The JavaScript Math
object is a built-in object that provides a variety of mathematical functions and constants. It allows you to perform complex mathematical calculations without needing to write your own logic. Let's break down the essential aspects you should know about the Math
object.
Not a Medium member? Read this article here
1. Basics of the Math Object
- The
Math
object is not a constructor, meaning you cannot instantiate it usingnew Math()
. - All
Math
properties and methods are static; you call them directly usingMath.methodName()
orMath.propertyName
.
2. Commonly Used Math Properties
Here are some of the useful properties that represent mathematical constants:
3. Math Methods
The Math
object includes many methods for performing mathematical calculations. Below are some of the most important methods: