How to use sin in JavaScript

In this article, I will explain use of sin() method in JavaScript.
  • 2265

JavaScript sin() Method

  • sin() method of math object is used to get the sine of a number.

  • sin() method returns a numeric value between -1 and 1.

  • In sin() method, numeric value represents the sine of the parameter.

Syntax

Math.sin(x)

  • x is a Required number

Example

In the following example show to sin() method returns the sine of numbers.

<html>

<head>

</head>

<body>

<h3 style="color:Blue">JavaScript sin() Method Example</h3>

<script type="text/javascript">

    var a = Math.sin(30);

    document.write("First Test sin Value : " + a);

    var b = Math.sin(60);

    document.write("<br />Second Test sin Value : " + b);

    var c = Math.sin(0);

    document.write("<br />Third Test sin Value : " + c);

    var d = Math.sin(Math.PI / 2);

    document.write("<br />Fourth Test sin Value : " + d);

</script>

</body>

</html>

Output

sin method.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.