Math.abs(x)
此方法返回数字的绝对值。
语法 (Syntax)
Math.abs( x ) ;
参数 (Parameter)
- X - 代表一个数字
返回值 (Return Value)
返回数字的绝对值
例子 (Example)
console.log("---Math.abs()---")
console.log("Math.abs(-5.5) : "+Math.abs(-5.5))
console.log("Math.abs(5.5) : "+Math.abs(5.5))
输出 (Output)
---Math.abs()---
Math.abs(-5.5) : 5.5
Math.abs(5.5) : 5.5