let x = Math.abs(-7.25);
Try it Yourself »
let a = Math.abs(7.25);
let b = Math.abs(-7.25);
let c = Math.abs(null);
let d = Math.abs("Hello");
let e = Math.abs(2-3);
Try it Yourself »
The Math.abs()
method returns the absolute value of a number.
Math.abs(
x)
Parameter | Description |
x | Required. A number. |
Type | Description |
Number | The absolute value of the number.NaN if the value is not a number.0 if the value is null . |
Math.abs()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!