function greeter(person:Boolean) {
return "Hello, " + person;
}
// let user = "Jane User";
// let user=[1,2,3]
// 1.布尔类型
let user:Boolean =true;
//2.数字
let num:number=1;
//3.数组
let arr:Array<number>=[2,4,5]
let arr2:number[]=[2,4,5]
//4.元组
let tup:[string,number];
tup=["2",3]
let tup2:[string,number]=["2",3];
//5.枚举
enum Color {Red = 1, Green, Blue}
let colorName: string = Color[2];
console.log(colorName); // 显示'Green'因为上面代码里它的值是2
document.body.innerHTML = greeter(user)+colorName;
网友评论