tan()  Math  class methodS2C Home  « Globals « Math « tan()

Description

Returns the tangent of a number in radians.

  • Radians to Degrees - divide number by (Math.PI / 180).
  • Degrees to Radians - multiply number by (Math.PI * 180).
  • Like all class methods tan() should be used on the class rather than an instance of the class.

Syntax

Signature Description
Math.tan(value)Returns the tangent of a number in radians.

Parameters

Parameter Description
valueThe value you wish to find the tangent of a number in radians of:
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 0.

Examples

The code below displays tan() usage.


/*
 * Store results in an array.
 */ 
var tanValues = new Array(6);
tanValues[0] = Math.tan(-1);
tanValues[1] = Math.tan(0);
tanValues[2] = Math.tan('0.75');
tanValues[3] = Math.tan('a string');
tanValues[4] = Math.tan();
tanValues[5] = Math.tan(null);
alert(tanValues);  

Press the button below to action the above code:


Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math

go to home page Homepage go to top of page Top