function test(a: string ,b?: string ,c: string = "default") {
console.log(a);
console.log(b);
console.log(c);
}
test("mike")
可以看到 ?代表可选属性 =赋值代表默认属性 默认属性和可选属性 调用的时候都不需要赋值
运行结果如下
function test(a: string ,b?: string ,c: string = "default") {
console.log(a);
console.log(b);
console.log(c);
}
test("mike")
可以看到 ?代表可选属性 =赋值代表默认属性 默认属性和可选属性 调用的时候都不需要赋值
运行结果如下