-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
126 lines (82 loc) · 2.14 KB
/
index.ts
File metadata and controls
126 lines (82 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function sum(x: number, y: number) {
return x+y;
}
const result = sum(5, 10);
let strOne: string = "Typescript";
//strOne = 10;
let booleanValue: boolean = true;
//booleanValue = "Typescript";
// Array
let arrayItem: Array<number | boolean | string> = [ "One", "Two", "Three", 12, true, "Four", "Five", "Six", false, 20];
//Tuble
let tubleArray: [string, number] = [ "One", 1];
// Union
let unionType: ( number | string | boolean );
unionType = "One";
unionType = 12;
unionType = true;
let normalType: string = "One";
console.log("Array Result: ", arrayItem);
console.log("Result Log: ", result);
// any
let anyType: any = "Welcome";
anyType = 2;
anyType = true;
/**
* ***********************************************
* Session II
*/
enum ColorConstant {
ORANGE,
GREEN = handleValue()
}
function handleValue():number {
return 50
}
console.log("Enum Value Green : ", ColorConstant.GREEN);
console.log("Enum Value Orange: ", ColorConstant.ORANGE);
enum CarConstant {
CAR1 = "Honda",
CAR2 = "Farrai"
}
console.log("Enum Value: ", CarConstant.CAR1);
// {
// GREEN = 0,
// ORANGE =1,
// BLUE = 2
// }
// Interface
interface StudentInfo {
firstName: string,
lastName: string,
mobile: number,
location: string,
getFirstName: () => string,
getMobileNumber: () => number
}
class Student implements StudentInfo {
firstName: string;
lastName: string;
mobile: number;
location: string;
constructor(fname: string, lname: string, mobile: number, location: string) {
this.firstName = fname;
this.lastName = lname;
this.mobile = mobile;
this.location = location;
}
getFirstName(): string {
return this.firstName;
}
getLastName(): string {
return this.lastName;
}
getMobileNumber(): number {
return this.mobile;
}
}
let studentObj = new Student("Kumar", "R", 9090909090, "Erode");
let firstName = studentObj.getFirstName();
let mobileNumber = studentObj.getMobileNumber();
console.log("Get Student First Name: ", firstName);
console.log("Get Student Mobile Number: ", mobileNumber);