function sum10(obj: { a: number, b: number }): number {
let {a, b} = obj
return a + b
}
不必传的参数写法
function sum4(obj: { a: number, b?: number }): number {
let {a, b = 100} = obj;
return a + b
}
function sum10({a: number, b: number}): number {
return a + b
}
function sum1({a, b}: { a: number, b: number }): number {
return a + b
}
function sum2({a, b = 100}: { a: number, b?: number }): number {
return a * 10 + b
}
网友评论