2_函数的参数.ts 438 B

12345678910111213141516171819202122
  1. (() => {
  2. //可选参数
  3. // function buildName(firstName: string = 'A',lastName?:string):string{
  4. // if(lastName){
  5. // return firstName + lastName
  6. // } else{
  7. // return firstName
  8. // }
  9. // }
  10. // console.log(buildName('C','D'))
  11. // console.log(buildName('C'))
  12. // console.log(buildName())
  13. //剩余参数
  14. function info(x:string,...args:string[]){
  15. console.log(x,args)
  16. }
  17. info('abc','a','b','c')
  18. })()