Tutorialspoint.dev

Math.sin( ) In JavaScript

The Math.sin() function in Javascript is used to return the sine of a number.
The Math.sin() method returns a numeric value between -1 and 1, which represents the sine of the angle given in radians.
sin() is a static method of Math, therefore, it is always used as Math.sin(), rather than as a method of a Math object created.

Syntax:

Math.sin(value)

Parameters Used:
Value:A number given in radians.

Return Value:
The Math.sin() function returns the sine of the given numbers.

Examples:



Input : Math.sin(0)
Output : 0
     
Input : Math.sin(1)
Output : 0.8414709848078965

Input : Math.sin(Math.PI / 2)
Output : 1

  1. When zero is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.sin(0));
    </script>

    Output:

    Output : 0
  2. When 1 is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.sin(1));
    </script>

    Output:

    Output : 0.8414709848078965
  3. When PI is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.sin(Math.PI / 2));
    </script>

    Output:

    Output : 1


This article is attributed to GeeksforGeeks.org

You Might Also Like

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter