Math - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

[Symbol.toStringTag]

The initial value of the [Symbol.toStringTag] property is the string "Math". This property is used in Object.prototype.toString().

Object.prototype.toString()

The initial value of the [Symbol.toStringTag] property is the string "Math". This property is used in Object.prototype.toString().

Calculating the height of an equilateral triangle

Calculating the height of an equilateral triangle

If we want to calculate the height of an equilateral triangle, and we know its side length is 100, we can use the formulae length of the adjacent multiplied by the tangent of the angle is equal to the opposite.

Returning a random integer between two bounds

This can be achieved with a combination of Math.random() and Math.floor():

Returning a random integer between two bounds

This can be achieved with a combination of Math.random() and Math.floor():

Learn how to contribute

This page was last modified on Jul 10, 2025 by MDN contributors.

Community resources

Writing guidelines

a Creative Commons license

Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.