TypeScript笔记一

/**
 * Created by ufo9631 on 2017/5/16.
 */
/*参数新特性*/
var maname = "zhang san"; //声明字符串类型变量
var alias = "xixi"; //任意类型
var age = 12; //整形
var man = false; //布尔类型
function test() {
}
function testStr() {
    return ""; //必须要有默认值
}
function testStr1(name) {
    return ""; //必须要有默认值
}
function testStr2(name) {
    console.log(name);
}
var Person = (function () {
    function Person() {
    }
    return Person;
}());
var zhangsan = new Person(); //使用自定义类型
zhangsan.age = 18;
zhangsan.name = "张三";
/*给方法指定默认值*/
function test2(a, b, c) {
    if (c === void 0) { c = "jojo"; }
    console.log(a);
    console.log(b);
    console.log(c);
}
test2("hah", "heh");
/*可选参数 b?:string  可以不传 ,必须写在必选参数后面*/
function test3(a, b, c) {
    if (c === void 0) { c = "jojo"; }
    console.log(a);
    console.log(b);
    console.log(c);
}
test3("sdf");
testStr2(123);
//# sourceMappingURL=ts2.js.map

  

原文地址:https://www.cnblogs.com/sumg/p/7841415.html