Math.abs() Absolute value
Last updated: 2026-09-09
Math.abs() Absolute value
Math.abs returns the absolute value.
| Category | Math |
|---|---|
| ES version | ES1 |
📝 Syntax
Math.abs(number);
⚙️ Parameters
| number | The number. |
|---|
Returns:The absolute value.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
5
5
0
3.14
ℹ️ info All Math methods are static — no instance needed.
💡 Tip Math.abs(a - b) for distance between two values.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| Math.abs() | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Items
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
QMath.abs(-Infinity)?
AReturns Infinity.
QWhat if the argument is a string?
ACoerced to number — Math.abs('-5') returns 5.
QMath.abs(null)?
AReturns 0 — null coerces to 0.