Math对象为数学常量和函数提供属性和方法。与其他全局对象不同,Math不是构造函数。Math的所有属性和方法都是静态的,可以通过将Math作为对象来调用,而无需创建它。本文主要介绍JavaScript(JS) Math.asin( x ) 方法。

1、描述

此方法返回一个数字的弧度反正弦值。asin方法对于x-11之间返回一个介于-pi/2pi/2弧度之间的数值。如果x的值超出这个范围,则返回NaN

2、语法

它的语法如下:

Math.asin( x ) ;

3、参数

x:一个数字。

4、返回值

返回一个数字弧度反正弦值。

5、使用示例

<html>  
   <head>
      <title>JavaScript Math asin() Method</title>
   </head>
   
   <body>
      <script type = "text/javascript">
         var value = Math.asin(-1);
         document.write("-1 : " + value );
         
         var value = Math.asin(null);
         document.write("<br />null : " + value ); 
         
         var value = Math.asin(20);
         document.write("<br />20 : " + value ); 
         
         var value = Math.asin("string");
         document.write("<br />string : " + value ); 
      </script>      
   </body>
</html>

6、输出

-1 : -1.5707963267948966
null : 0
20 : NaN
string : NaN

推荐文档