offline version v3


41 of 264 menu

Math.abs

The Math.abs method returns the modulus (or absolute value) of a number, that is, it makes a positive number from a negative number.

Syntax

Math.abs(number);

Example

Let's output the modulus of the number -3:

console.log(Math.abs(-3));

The code execution result:

3

Example

Let's output the modulus of the number 3:

console.log(Math.abs(3));

The code execution result:

3
enru