JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




Math.cos() Method - Math Functions


Tutorials Javascript

Topic

Math.cos() method of Math Functions in Javascript.
How to get the cosine value of a number in javascript?



Explanation

Object: Math

Method: Math.cos()

Description: To get the cosine value for a number specified as radians. The function returns a value between -1 and 1 for the given number. The below example will get Cosine value for numbers 0, PI using Math Functions.

Example:
<script type="text/javascript">
document.write('Cosine of 0 is::'+Math.cos(0));
document.write('
');
document.write('Cosine of PI is::'+Math.cos(Math.PI));
</script>

Result:


In the above example,
  • First the cosine value of "0" is got as "1".
  • To get the cosine value of "PI" we have used "Math.PI" function, it returns "-1".






  • A Note
    Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

    Other Links

    web hosting