javascript之Math对象——绝对值,开次方,四舍五入

javascript的Math对象有多种计算方法

1.取绝对值

语法是Math.abs(数值)

Math.abs(2.4)

结果是2

2.求一个数的几次方

语法是Math.pow(数值,幂),比如说计算2的3次方

Math.pow(2,3)

3.四舍五入

语法是Math.round(数值),比如对3.6进行四舍五入

Math.round(3.6)