How to Use the acos () method in JavaScript
Returns the arc cosine of the radians returned by this method. The ACOS method returns the radians between 0 and PI for the X-1 and 1. If the number value exceeds this range, NaN is returned.
Syntax
The following is the detailed information about the parameters:
Return Value:
- Returns the arc cosine of radians.
Example:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<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 produces the following results:
| 1 2 3 4 |
First Test Value: 3.141592653589793 Second Test Value: 1.5707963267948965 Third Test Value: NaN Fourth Test Value: NaN |