1、描述
此方法返回数字的绝对值。
2、语法
它的语法如下:
Math.abs( x )
3、参数
x:一个数字。
4、返回值
返回数字的绝对值。
5、使用示例
<html>  
   <head>
      <title>JavaScript Math abs() Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var value = Math.abs(-1);
         document.write("-1 : " + value ); 
         
         var value = Math.abs(null);
         document.write("<br />null : " + value ); 
         
         var value = Math.abs(20);
         document.write("<br />20 : " + value ); 
         
         var value = Math.abs("string");
         document.write("<br />string : " + value ); 
      </script>   
   </body>
</html>6、输出
-1 : 1 null : 0 20 : 20 string : NaN