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
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
- <!DOCTYPEhtml>
- <htmllang="en"
- xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <metacharset="utf-8"/>
- <title>Tangent function</title>
- <linkrel="stylesheet"href="app.css"type="text/css"/>
- <scriptsrc="app.js">
- </script>
- </head>
- <body>
- <h1>tan() function in TypeScript HTML App</h1>
- <scriptsrc="app.js">
- </script>
- <divid="content"/>
- </body>
- </html>
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
Referenced By
http://www.typescriptlang.org/