Core JavaScript 1.5 Reference:Global Objects:Math:tan
From MDC
(Redirected from Core JavaScript 1.5 Reference:Objects:Math:tan)
Contents |
[edit] Summary
Returns the tangent of a number.
| Method of Math | |
|
Static |
|
| Implemented in: | JavaScript 1.0, NES 2.0 |
| ECMA Version: | ECMA-262 |
[edit] Syntax
Math.tan(x)
[edit] Parameters
-
x - A number representing an angle in radians.
[edit] Description
The tan method returns a numeric value that represents the tangent of the angle.
Because tan is a static method of Math, you always use it as Math.tan(), rather than as a method of a Math object you created.
[edit] Examples
[edit] Example: Using Math.tan
The following function returns the tangent of the variable x:
function getTan(x) {
return Math.tan(x)
}
Because the Math.tan() function accepts radians, but it is often easier to work with degrees, the following function accepts a value in degrees, converts it to radians and returns the tangent.
function getTanDeg(deg) {
var rad = deg * Math.PI/180;
return Math.tan(rad)
}