Standard built-ins
Math.abs()
Absolute magnitude; converts -0 to +0. Converts x to Number; BigInt conversion throws TypeError.
Formal Syntax & Structure
javascript syntaxjavascript
Math.abs(x)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | number | Number input or value coercible to Number. |
Return Value
number
Result of the numerical operation, possibly NaN.
Working Example
Example Snippetjavascript
console.log(Math.abs(-8));