1.ts基础类型

作者: iqing2012 | 来源:发表于2018-04-28 01:14 被阅读4次
    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;
    

    相关文章

      网友评论

        本文标题:1.ts基础类型

        本文链接:https://www.haomeiwen.com/subject/qtswlftx.html