- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
The Math object in JavaScript provides a variety of methods to perform mathematical tasks on numbers. It includes methods for rounding, trigonometry, logarithms, and more.
Example: Rounding Methods
console.log(Math.round(4.6)); // 5console.log(Math.ceil(4.2)); // 5console.log(Math.floor(4.9)); // 4console.log(Math.trunc(4.9)); // 4Copied!✕CopyCommon Math Methods
1. Math.abs(x)
Returns the absolute value of x.
console.log(Math.abs(-4.7)); // 4.7Copied!✕Copy2. Math.pow(x, y)
Returns the value of x to the power of y.
console.log(Math.pow(8, 2)); // 64Copied!✕Copy3. Math.sqrt(x)
Returns the square root of x.
console.log(Math.sqrt(64)); // 8Copied!✕Copy4. Math.random()
Returns a random number between 0 (inclusive) and 1 (exclusive).
console.log(Math.random()); // e.g., 0.123456789Copied!✕Copy5. Math.min() and Math.max()
Returns the lowest or highest value in a list of arguments.
console.log(Math.min(0, 150, 30, 20, -8, -200)); // -200console.log(Math.max(0, 150, 30, 20, -8, -200)); // 150Copied!✕CopyImportant Considerations
Math - JavaScript | MDN - MDN Web Docs
JavaScript Math Object - W3Schools
The Math Object The JavaScript Math object allows you to perform mathematical tasks. The Math object is static. All methods and properties can be used without creating a Math object first.
JavaScript Math Object - GeeksforGeeks
Jul 11, 2025 · JavaScript Math object is used to perform mathematical operations on numbers. All the properties of Math are static and unlike other objects, it does not have a constructor.
JavaScript - Math - Online Tutorials Library
The JavaScript math object provides properties and methods for mathematical constants and functions. Unlike other global objects, Math is not a constructor. …
Math - The complete JavaScript Tutorial
For a full list of the methods found on the Math object, please see this reference. With that in mind, here's a list of the most relevant and interesting methods found on the Math object.
Math - JavaScript | MDN
Jun 27, 2017 · All properties and methods of Math are static. You refer to the constant pi as Math.PI and you call the sine function as Math.sin(x), where x is the method's argument. Constants are defined …
JavaScript Math Object - Programiz
Math is not a constructor function. It's a property of the implicit global object. In this reference page, you will find all methods of Math object. You can access methods and constants of the Math object …
JavaScript Math Object: A Comprehensive Guide - tutorialpedia.org
In this blog post, we will explore the Math object in detail, covering its fundamental concepts, usage methods, common practices, and best practices. The Math object in JavaScript is a static object, …
JavaScript Math Operations: Useful Methods and Examples
Understanding the Math object’s methods can significantly enhance your ability to write efficient and accurate JavaScript code. In this blog post, we will explore some of the most useful methods of the …
Basic math in JavaScript — numbers and operators - MDN Web Docs
Aug 18, 2025 · At this point in the course, we discuss math in JavaScript — how we can use operators and other features to successfully manipulate numbers to do our bidding.