A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-math-abs-method/ below:

JavaScript Math abs() Method - GeeksforGeeks

JavaScript Math abs() Method

Last Updated : 15 Jul, 2024

Javascript Math.abs() method is used to return the absolute value of a number. It takes a number as its parameter and returns its absolute value.

Syntax:
Math.abs(value)
Parameters:

This method accepts a single parameter as mentioned above and described below:

Return Value:

The absolute value of the number passed as a parameter. The below examples illustrate the Math abs( ) method in JavaScript:

Example 1: This example shows the use of the Math.abs() method in javascript.

JavaScript
console.log(Math.abs(2));
console.log(Math.abs(2.56));

Example 2: This example shows the return value of Math.abs() method when the parameter is a string value.

JavaScript
console.log(Math.abs("Geeksforgeeks"));

Example 3: This example shows the return value of Math.abs() method when the parameter is an arithmetic expression.

JavaScript
console.log(Math.abs(7+9));        
Errors and Exceptions:

We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.

Supported Browsers

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4