Built-In Mathematical Calculations
Math
is a built-in object with properties and methods for mathematical constants and functions. It is not a function object. Math works with the Number type. Math functions are all static, so each starts with Math.myfunctioncallhere()
. Math.PI
and Math.random()
are two Math functions used a lot when doing calculations.
Description
Math
The Math
namespace object contains static properties and methods for mathematical constants and functions.
Math
works with the Number
type. It doesn't work with BigInt
.
Description
Unlike most global objects, Math
is not a constructor. You cannot use it with the new
operator or invoke the Atomics
object as a function. All properties and methods of Math
are static.
Note: Many Math
functions have a precision that's implementation-dependent.
This means that different browsers can give a different result. Even the same JavaScript engine on a different OS or architecture can give different results!
Source: Mozilla, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.