作用 : 返回一个数的绝对值

Math.abs(x) 参数x必须是一个数值
返回值: Number x 的绝对值。如果 x 不是数字返回 NaN,如果 x 为 null 返回 0。

例如:

var a=Math.abs(7.25);
var b=Math.abs(-7.25);
var c=Math.abs(null);
var d=Math.abs("Hello");
var e=Math.abs(2+3);

输出:

7.25
7.25
0
NaN
5
文章目录