摘要:
infer 表示待推断的返回值类型 使用场景: 返回参数、返回值的类型 // 获取参数类型 type ConstructorParameters<T extends new (...args: any[]) => any> = T extends new (...args: infer P) => 阅读全文
摘要:
应用场景:1、处理多种数据类型,2、当函数、接口或类在多个地方使用该数据类型时 分类: (1)泛型接口: interface Identities<V,M> { value: V, message: M} (2)泛型函数: function Fn<V,M>(value: V, message: M) 阅读全文
摘要:
Set && Map : 共同点:快速查找值 Set特点:唯一值 Map : 键值对 for-of : 循环是一种可迭代对象的方法 for-in : 循环会遍历对象的原型链,包括不是自身的属性也会遍历,可以使用hasOwnProperty 方法来检查属性是否为对象自身的属性。 阅读全文