Definition and Usage The abs() method returns the absolute value of a number. Syntax Math.abs(x) Parameter Description ...
Definition and Usage
The abs() method returns the absolute value of a number.
Syntax
Parameter | Description |
x | Required. Must be a numeric value |
Example
In this example get the absolute values of positive and negative numbers:
<script type="text/javascript"> document.write(Math.abs(7.25) + "<br />");
document.write(Math.abs(-7.25) + "<br />");
document.write(Math.abs(7.25-10)); </script> |
The output of the code above will be: