2-1. 函数的传参

  1. function fun(s:string):string{
  2. console.log(s);
  3. return s;
  4. }
  5. fun("hello");

1.默认参数

  1. function fun(s:"hello world"):string{
  2. console.log(s);
  3. return s
  4. }
  5. fun("good");
  6. # // 当函数没有传值时,函数会调用默认参数值

2. 返回值是任何类型

  1. function fun(s:any):any{
  2. return s
  3. }