好处:兼顾了灵活性和类型检查

1-1. 定义一个泛型函数

  1. function goTest<T>(s:T):T{
  2. return s
  3. }
  4. goTest<string>("1000");
  5. goTest<number>(100);