-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
93 lines (69 loc) · 2.34 KB
/
app.ts
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
import { StudentInfo } from './IStudentInfo';
import { Students } from './Student';
console.log("Hello ExecuteAutomation");
let a: number = 10;
let b: string = "String";
var k: Number = 101;
console.log(a);
//Enums
enum LanguageKnown { English, Hindi, Malayalam };
let student: StudentInfo = {
Name: "Karthik",
Age: 30,
Phone: 9847012345,
Language: LanguageKnown[LanguageKnown.Hindi]
};
//Arrays
let studentsList: StudentInfo[] = [
{ Name: "Prasanth", Age: 26, Phone: 9995012345, Language: LanguageKnown[LanguageKnown.English] }
];
studentsList.push(student);
// for (let index = 0; index < studentsList.length; index++) {
// const element = studentsList[index];
// console.log("Age:" + element.Age + " with Name:" + element.Name + " has Phone:" + element.PhoneNumber + " speaks:" + element.Language);
// }
//Function
function GetStudentsList(students: StudentInfo[]) {
students.forEach(element => {
console.log("Age:" + element.Age + " with Name:" + element.Name + " has Phone:" + element.Phone + " speaks:" + element.Language);
})
};
GetStudentsList(studentsList);
//Function Rest Parameters
function GetNumbers(...nums: Number[]) {
nums.forEach(element => {
console.log("Number: " + element);
});
};
GetNumbers(1, 2, 3, 4, 5, 6);
//Default Parameters
function GetInfo(info: string = "Happy") {
console.log(info);
};
GetInfo();
GetInfo("Very Happy");
/*************************************************** */
//Anonymous Function
let StudentName = function (lName: string, fName: string) {
return fName + "..." + lName;
};
console.log(StudentName("Shaheer", "Muhammed"));
//Arrow Function
let StudentFullName = (lName: string, fName: string) => {
return fName + ".." + lName;
};
console.log(StudentFullName("Shaheer", "Muhammed"));
/****************************************** */
//Classes
let s = new Students("Shaheer", "Muhammed");
console.log(s.GetFullName());
//Generics
let studentsListG: Array<StudentInfo> = [
{ Name: "Prasanth", Age: 26, Phone: 9995012345, Language: LanguageKnown[LanguageKnown.English] }
];
function GetStudentsListGenerics(students: Array<StudentInfo>) {
students.forEach(element => {
console.log("Age:" + element.Age + " with Name:" + element.Name + " has Phone:" + element.Phone + " speaks:" + element.Language);
})
};
GetStudentsList(studentsListG);