Math.abs()
Math.abs(x)
函数返回指定数字 “x“ 的绝对值。如下:
语法
Math.abs(x);
参数
x
- 一个数值
说明
由于 Math.abs()
是 Math
中的一个静态方法,你应该通过 Math.abs()
调用。(Math 不是构造器)
示例
Math.abs() 函数的行为
规范
规范版本 | 规范状态 | 注解 |
---|---|---|
ECMAScript 1st Edition. Implemented in JavaScript 1.0 | Standard | Initial definition. |
ECMAScript 5.1 (ECMA-262) Math.abs |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Math.abs |
Standard |
浏览器兼容性
BCD tables only load in the browser
相关链接
- The
Math
object it belongs to. Math.ceil()
Math.floor()
Math.round()