Math.abs()
ES1+Returns the absolute value of a number.
Syntax
Math.abs(x)Parameters
x number A number
Return Value
number
The absolute value of the given number
Examples
JavaScript
console.log(Math.abs(-5));
console.log(Math.abs(5));
console.log(Math.abs(-3.14)); Output:
// 5
5
3.14