-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathts_data.ts
71 lines (57 loc) · 1.31 KB
/
ts_data.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
let num1 : number = 3;
let num2: number = 5;
let str1: string = "string";
let str2: string = "test";
let numArr:Array<number> = [3,5,6];
let numArr2:number[] = [3,4,5];
// console.log(num1);
// console.log(numArr);
let tp :[string, number];
tp = ["1",2];
let anyTest : any = "any";
anyTest = 3;
anyTest = true;
anyTest = new Number(3);
let anyArr : any[] = [1,2,3];
function setUser():string{
return "test";
}
function testObject(){
return "abc";
}
var strTest = testObject();
console.log(strTest.charAt(1));
console.log(strTest.length);
console.log(strTest.substr(1));
console.log(strTest);
function testFunc(str:string, num:number):void{
console.log("str = " + str);
console.log("num = " +num);
}
testFunc("문자열",330);
function throwError():never{
throw new Error("nonono");
}
interface testIter{
str : string,
num : number;
}
let AjaxUtil = function(ti:testIter){
this.print = function():void{
console.log(ti.str);
console.log(ti.num);
}
}
var test1 = {str:"홍길동", num:30}
var au = new AjaxUtil(test1);
au.print();
class Car{
carName : string;
constructor(public pCarName:string){
this.carName = pCarName;
}
}
let hyundai:Car = new Car("Sonata");
let pStr:string = "hyundai자동차중 제 차는 : ";
pStr += hyundai.carName;
console.log(pStr);