ts函数默认值
//函数默认值
const fun = (num1: number = 12, num2: number = 24): number => {
return num1 + num2
}
fun()
ts函数可选参数
//函数默认值
const fun = (num1: number = 12, num2?: number ): number => {
return num1 + num2 ? num2 : 0
}
fun()
本文转自 https://blog.csdn.net/qq_43291759/article/details/119760720,如有侵权,请联系删除。