This JavaScript tutorial explains how to use the math feature known as tan() with syntax and examples.
Description
In JavaScript, tan() is a characteristic that is used to return the tangent of a number. Because the tan() function is a static characteristic of the Math object, it should be invoked via the placeholder object known as Math.
Syntax
In JavaScript, the syntax for the tan() function is:
Math.tan(number);
Parameters or Arguments
number The range used to calculate the tangent. It is the price of an perspective expressed in radians.
Returns
The tan() function returns the tangent of a number.
Note
To convert stages to radians, multiply through 2π/360 or 0.017453293. Math is a placeholder object that incorporates mathematical features and constants of which tan() is one of these functions.
Example
Let’s take a look at an example of how to use the tan() function in JavaScript.
For example:
console.log(Math.tan(2));
console.log(Math.tan(0));
console.log(Math.tan(-0.9));
In this example, we have invoked the tan() feature the use of the Math class.
We have written the output of the tan() feature to the web browser console log, for demonstration purposes, to show what the tan() function returns.
The following will be output to the net browser console log:
-2.185039863261519
0
-1.2601582175503392
In this example, the first output to the console log returned -2.185039863261519 which is the tangent of 2
The 2nd output to the console log back 0 which is the tangent of 0
The 1/3 output to the console log returned -1.2601582175503392 which is the tangent of -0.9.
Leave a Review