JavaScript sin

The JavaScript sin function is a Math function that calculates the Trigonometry Sine for the specified expression. The syntax of the sin Function:

Math.sin(number);

The JavaScript sin function returns the sine value between -1 and 1. The mathematical formula of the Javascript Trigonometry Sine function:

SIN(x) = Length of the Opposite Side / Length of the Hypotenuse

JavaScript sin Function Example

In this example, we will find the Sine values of different data types and display the output. The first four statements are all about positive and negative values.

For Str, we tried this method on the string value. It will return NaN (Not a Number).

Next, we tried this Math function on the Null value, which returns Zero as output. In the last statement, We used it on multiple values.

TIP: Please refer to the asin method to find the JavaScript Arc Sine.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScriptSINFunction </title>
</head>
<body>
  <h1> JavaScriptSINFunction </h1>
  <p id = "Pos"></p>
  <p id = "Neg"></p>
  <p id = "Dec"></p>
  <p id = "Neg_Dec"></p>
  <p id = "Str"></p>
  <p id = "Exp"></p>
  <p id = "Null"></p>
  <p id = "Multi"></p>
  <script>
    document.getElementById("Pos").innerHTML = Math.sin(20);
    document.getElementById("Neg").innerHTML = Math.sin(-10);
    document.getElementById("Dec").innerHTML = Math.sin(40.45);
    document.getElementById("Neg_Dec").innerHTML = Math.sin(-60.75);
    document.getElementById("Str").innerHTML = Math.sin("JavaScript");
    document.getElementById("Null").innerHTML = Math.sin(null);
    document.getElementById("Multi").innerHTML = Math.sin(25 + 55 - 77);
  </script>
</body>
</html>
JavaScript SIN Function example