
The JavaScript Math.sin() returns the sine of a number.
Syntax:
Math.sin(number)
Note: JavaScript Math.sin(x) returns a value between -1 and 1, which represents the sine of the parameter x, or NaN if the value is empty.
Example:
<!DOCTYPE html>
<html>
<body>
<p id="example"></p>
<script>
let a = Math.sin(2);
let b = Math.sin(-2);
let c = Math.sin(0);
let d = Math.sin(Math.PI);
let e = Math.sin(Math.PI / 2);
let f = Math.sin();
document.getElementById("example").innerHTML =
a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e + "<br>" + f;
</script>
</body>
</html>
Output:
JavaScript Math.sin() returns the sine of a number:
Enjoy coding!
Read also: