let sum3 =(a:string, b?:string):string=>{// ?:return a + b;};sum3('a');// 可选参数必须在其他参数的最后面
3. 默认参数
let sum4 =(a:string, b:string='b'):string=>{return a + b;};sum4('a');// 默认参数必须在其他参数的最后面
4. 剩余参数
const sum =(...args:string[]):string=>{console.log(' 4. 剩余参数', args)return args.reduce((memo, current)=> memo += current,'')}sum('a','b','c','d')// sum(1, 'a', 'b', 'c', 'd') // Argument of type 'number' is not assignable to parameter of type 'string'.