Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Module

Math

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.

How it works

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.

Key points

  • Use Math as the standard namespace for built-in mathematical constants and functions.
  • Access members directly, for example Math.PI or Math.max(), without creating an object.
  • Math is designed for Number calculations rather than arbitrary numeric types.
  • Its API combines named constants with callable operations for common mathematical tasks.
  • Floating-point results from some functions are not guaranteed to be identical across implementations.

Common mistakes

  • Math methods are for Number values, so passing BigInt values is not supported.
  • Do not call Math with new or treat it as a callable constructor.
  • Some results can vary between browsers or across operating systems and architectures.

Example: Using Math constants and methods

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.

When to use it

Numeric formulas

Calculating geometry or physical quantities with constants and arithmetic helpers.

Mathematical transformations

Applying trigonometric, logarithmic, exponential, or rounding operations to Number values.

General numeric utilities

Generating values or selecting extrema with built-in static methods.

Interview questions

QWhat is the role of the Math object?

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.

QDoes Math support BigInt?

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.

QHow are Math members accessed, and what does it provide?

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.

  • Number
  • BigInt
  • Math.PI
  • Math.sin()
  • Math.max()
  • Math.random()

Source: Math - JavaScript | MDN. Checked 2026-10-15.