ARTICLE

# How to Use Tan Method in TypeScript

Posted by | October 15, 2012
In this article I will explain how to use tan() method in TypeScript with an example.

tan() Method in TypeScript

• The tan() method of the math object is used to get the tangent of a number.

• In the tan() method, the numeric value represents the tangent of the angle.

Syntax

 Math.tan(number);

The following example shows how to use the tan() method and it returns the tangent of numbers in radians. We use the following steps to use this method.

Step 1

Open Visual Studio 2012 and click "File" -> "New" -> "Project...". A window is opened. Give the name of your application as "tangent" and then click ok.

Step 2

After this session the project has been created; your new project should look like this:

Coding

tangent.ts

 class tangent {     constructor () {       }     tangentofnumber() {         for (var n = 1; n <= 10; n++) {             var span = document.createElement("span");             var num = Math.tan(n);             span.style.color = "green";             span.innerText = "Tangent of nun " + n + "->" + num.toString() + "\n";             document.body.appendChild(span);           }     }     tangentofangel()     {         for (var n = 1; n <= 6; n++)         {             var x = 30;             var z = 30 * n;                 var span = document.createElement("span1");                         var num = Math.tan(z);                 span.style.color = "blue";                 span.innerText = "Tangent of angels " + z + "->" + num.toString() + "\n";                 document.body.appendChild(span);          }       } } var s = new tangent(); s.tangentofnumber(); s.tangentofangel();

tangentfunctiondemo.html

         Tangent function

tan() function in TypeScript HTML App

app.js

 var tangent = (function () {     function tangent() {     }     tangent.prototype.tangentofnumber = function () {         for(var n = 1; n <= 10; n++) {             var span = document.createElement("span");             var num = Math.tan(n);             span.style.color = "green";             span.innerText = "Tangent of nun " + n + "->" + num.toString() + "\n";             document.body.appendChild(span);         }     };     tangent.prototype.tangentofangel = function () {         for(var n = 1; n <= 6; n++) {             var x = 30;             var z = 30 * n;             var span = document.createElement("span1");             var num = Math.tan(z);             span.style.color = "blue";             span.innerText = "Tangent of angels " + z + "->" + num.toString() + "\n";             document.body.appendChild(span);         }     };     return tangent; })(); var s = new tangent(); s.tangentofnumber(); s.tangentofangel();

Output

Reference By

http://www.typescriptlang.org/

 This Feature is Sponsored By .NET Diagramming framework designed for creating advanced solutions