let str: string = "学习ts第一天,2022226"
let num: number = 1;
let flag:boolean = true;
let arr: string[] = ['a', 'b', 'c']
console.log(arr);
let numArr: Array<number> = [1, 2, 3];
console.log(numArr);
let arrTapue: [Boolean, String, Number] = [false, 'string', 1]
console.log(arrTapue);
enum pay_status {
non_payment = 0,
payment = 1,
success = 2
}
let f: pay_status = pay_status.non_payment
console.log(f);
enum color { blue, red, orange, yellow = 6 }
console.log(color.red, color[0], color[6]);
let tmp: any = 123;
tmp = 'string'
tmp = true
tmp = [1, 2, 3]
console.log(tmp);
let b: undefined;
console.log(b);
let a: number | string | undefined;
a = '123'
console.log(a);
function run() {
console.log('run');
}
run();
function run1(): void {
console.log('run1 ts');
}
run1();
function runNumber(): number {
return 123
}
|