Return the absolute value of a number:
The result will be:
More "Try it Yourself" examples below.
The abs() method returns the absolute value of a number.
Method | |||||
---|---|---|---|---|---|
abs() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
x | Required. A number |
Return Value: | A Number, representing the absolute value of the specified number, or NaN if the value is not a number, or 0 if the value is null |
---|---|
JavaScript Version: | 1.0 |
Return the absolute value of different numbers:
The result of a,b,c,d, and e will be: