指在定义函数、接口或类的时候,没有定义具体类型,等到使用的时候才指定具休类型的特征

    在函数名后使用 <>,在其中定义泛型参数

    1. function createArray<T>(length: number, value: T): T[] {
    2. const arr = Array<T>(length).fill(value);
    3. return arr;
    4. }