随笔分类 - 前端歌谣ts-学习-2022
前端ts-学习-2022
摘要:export default {} // interface IKeyInterface { // [key: string]: any // } // let getProps = (obj: IKeyInterface, key: string): any => { // return obj[
阅读全文
摘要:export default {} // string number class Person<T1, T2> { name: T1; age: T2; sex: T1; constructor(name: T1, age: T2, sex: T1) { this.name = name; this
阅读全文
摘要:export default {} // interface IPerson { // name: string; // age: number; // } // let p: IPerson = { // name: "于文文", // age: 18 // } // interface IPer
阅读全文
摘要:export default {} // 演示可能会出现的问题 // function getLength<T>(arr: T): T { // console.log(arr.length); // return arr; // } // getLength<string>("孟子义"); //
阅读全文
摘要:export default {} // 不使用泛型 // let getArray = (value: number, items: number): number[] => { // return new Array(items).fill(value); // } // // let arr
阅读全文
摘要:export default {} // 变量声明的方式 // var | let | const // 数组解构 let goddess = ["邱淑贞", "赵雅芝", "张敏"]; let [ first, second, a, b] = goddess; // console.log(fir
阅读全文
摘要:export default {} // bight类型: 表示非常大的数 // symbol类型: 表示全局唯一引用 // ES2020可用 const Hundred1: bigint = BigInt(100) const Hundred2: bigint = 100n const first
阅读全文
摘要:export default {} /* enum`类型是对JavaScript标准数据类型的一个补充。 像C#等其它语言一样,使用枚举类型可以为一组数值赋予友好的名字。 */ // 枚举用于表示固定的几个取值 // 例如: 人的性别只能是男或者女 enum Gender { Male, Femal
阅读全文
摘要:export default {} // Never类型 // never类型表示的是那些永不存在的值的类型 // 例如: never类型是那些总是会抛出异常或根本就不会有返回值的函数表达式或箭头函数表达式的返回值类型 // 变量也可能是 never类型,当它们被永不为真的类型保护所约束时。 //
阅读全文
摘要:export default {} // TypeScript里,undefined和null两者各自有自己的类型分别叫做undefined和null。 // 和 void相似,它们的本身的类型用处不是很大 let x: undefined = undefined; let y: null = nu
阅读全文