The Math.tan() function in Javascript is used to return the tangent of a number.
The Math.tan() method returns a numeric value that represents the tangent of the angle.
tan() is a static method of Math, therefore, it is always used as Math.tan(), rather than as a method of a Math object created.
Syntax:
Math.tan(value)
Parameters Used:
Value:A number representing an angle in radians.
Return Value:
The Math.tan() function returns the tangent of the given numbers.
Examples:
Input : Math.tan(0) Output : 0 Input : Math.tan(1) Output : 1.557407724654902 Input : Math.tan(Math.PI / 4) Output : 0.9999999999999999
- When zero is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.tan(0));
</
script
>
Output:
Output : 0
- When 1 is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.tan(1));
</
script
>
Output:
Output : 1.557407724654902
- When PI is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.tan(Math.PI / 4));
</
script
>
Output:
Output : 0.9999999999999999
leave a comment
0 Comments