This JavaScript tutorial explains how to use the math characteristic called sin() with syntax and examples.
Description
In JavaScript, sin() is a function that is used to return the sine of a number. Because the sin() function is a static characteristic of the Math object, it ought to be invoked via the placeholder object referred to as Math.
Syntax
In JavaScript, the syntax for the sin() feature is:
Math.sin(number);
Parameters or Arguments
number The number used to calculate the sine. It is the value of an attitude expressed in radians.
Returns
The sin() function returns the sine of a number.
Note
To convert ranges to radians, multiply by using 2π/360 or 0.017453293. Math is a placeholder object that contains mathematical features and constants of which sin() is one of these functions.
Example
Let’s take a seem to be at an example of how to use the sin() feature in JavaScript.
For example:
console.log(Math.sin(2));
console.log(Math.sin(0));
console.log(Math.sin(-0.9));
In this example, we have invoked the sin() characteristic the use of the Math class.
We have written the output of the sin() function to the internet browser console log, for demonstration purposes, to show what the sin() function returns.
The following will be output to the internet browser console log:
0.9092974268256817
0
-0.7833269096274834
In this example, the first output to the console log again 0.9092974268256817 which is the sine of two
The 2nd output to the console log lower back zero which is the sine of zero
The third output to the console log back -0.7833269096274834 which is the sine of -0.9.
Leave a Review