Numeric formulas
Calculating geometry or physical quantities with constants and arithmetic helpers.
JavaScript · Module
Math is JavaScript’s built-in namespace for mathematical constants and functions operating on Number values. Its members are static, so use Math directly rather than constructing or calling it.
Math is a namespace of static constants and mathematical functions for Number values. Access members directly through Math; it is not constructible, and it does not provide operations for BigInt values.
const angle = Math.PI / 4;
const hypotenuse = 10;
const area = Math.pow(hypotenuse, 2) / 2;
const rounded = Math.round(area);
console.log({ angle, area, rounded });Uses a constant, trigonometric-ready angle, exponentiation, and rounding with static Math members.
Calculating geometry or physical quantities with constants and arithmetic helpers.
Applying trigonometric, logarithmic, exponential, or rounding operations to Number values.
Generating values or selecting extrema with built-in static methods.
Math is a global namespace object containing static mathematical constants and functions. Its members are used directly, such as Math.PI or Math.sin(value), rather than through an instance.
Follow-up: Can Math be subclassed or instantiated with new? No; Math is not a constructor, so new Math() is invalid.
Math functions operate with JavaScript's Number type. They do not operate with BigInt, so code must avoid passing BigInt operands to Math methods.
Follow-up: How should exact large-integer arithmetic be handled? Use BigInt operations where supported, rather than Math methods.
Math exposes static properties and methods, including constants and functions for common mathematical operations. Examples include Math.PI for a constant and Math.sin() for a function.
Follow-up: What input convention applies to trigonometric methods? Their angle arguments are in radians.
NumberBigIntMath.PIMath.sin()Math.max()Math.random()