The acos of method in JavaScript USES detail

  • 2020-06-15 07:40:23
  • OfStack

The arc cosine of the radian returned by this method. The ACOS method returns the values of 0 and PI for radians between ES3en-1 and 1. If the value of the number is outside this range, NaN is returned.
grammar


Math.acos( x ) ;

Here is the details of the parameters:

x: One number

The return value:

It returns the arccosine of 1 radian.

Example:


<html>
<head>
<title>JavaScript Math acos() Method</title>
</head>
<body>
<script type="text/javascript">

var value = Math.acos(-1);
document.write("First Test Value : " + value ); 
 
var value = Math.acos(null);
document.write("<br />Second Test Value : " + value ); 

var value = Math.acos(30);
document.write("<br />Third Test Value : " + value ); 

var value = Math.acos("string");
document.write("<br />Fourth Test Value : " + value ); 
</script>
</body>
</html>

This will produce the following results:


First Test Value : 3.141592653589793
Second Test Value : 1.5707963267948965
Third Test Value : NaN
Fourth Test Value : NaN 


Related articles: