Return the absolute value of a number:
The result will be:
The abs() method returns the absolute value of a number.
![]()
The abs() method is supported in all major browsers.
| Parameter | Description |
|---|---|
| x | Required. A number |
| Type | Description |
|---|---|
| Number | 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:
JavaScript Math Object
Your message has been sent to W3Schools.