09 2022 档案
摘要: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
阅读全文
摘要:export default {} // any类型 // any表示任意类型, 当我们不清楚某个值的具体类型的时候我们就可以使用any // 在TS中任何数据类型的值都可以赋值给any类型 // 场景一 // 变量的值会动态改变时,比如来自用户输入,任意值类型可以让这些变量跳过编译 let sal
阅读全文
摘要:export default {} // 元组类型 let tup1:[string, number, boolean]; tup1 = ["宋祖儿", 100, false]; // tup1 = ["宋祖儿", 100, false, "TRUE", 123]; // tup1 = [100,
阅读全文
摘要:export default {} // interface IKeyInterface { // [key: string]: any // } // let getProps = (obj: IKeyInterface, key: string): any => { // return obj[
阅读全文
摘要:export default {} // 数值类型 number let money:number; money = 123; money = 18; money = 20; // money = "邱淑贞"; // money = ["李一桐", "李嘉欣", "李艺彤"]; // money =
阅读全文
摘要:function test(msg) { console.log(msg.length); } test("邱淑贞"); // 3 test(); test(123); console.log("往后余生,风雪是你,平淡是你,敲每一行代码心里想的都是你"); console.log("你是CSS,我
阅读全文
摘要: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 {}; /* function testDecorator(constructor: any) { constructor.prototype.uname = "张予曦"; constructor.prototype.show = ():void => { consol
阅读全文
摘要:export default {} // 注意点: 可多不可少 interface INameTest { name: string; } let n1 = {name: "祝绪丹"}; let n2 = {name: "江疏影", age: 18}; let n3 = {age: 18}; let
阅读全文
摘要:export default {} // 因为TS是一个结构化的类型系统,类型参数只在作为成员类型的一部分被消耗时影响到结果类型 // interface Empty<T> {} // let x: Empty<number>; // let y: Empty<string>; // x = y;
阅读全文
摘要:export default {} // 注意点: 可多不可少 // class Animal { // feet: number; // age: number; // constructor(name: string, numFeet: number) {} // } // class Size
阅读全文
摘要:export default {} // 1.数字枚举 /* 注意点: 1.数字枚举的取值可以是字面量, 也可以是常量, 也可以是计算的结果 2.如果采用字面量对第一个成员进行赋值,下面的成员会自动递增 3.如果采用常量或计算结果进行赋值,则下面的成员也必须初始化 */ // enum Gender
阅读全文
摘要:export default {} // 参数个数 // 注意点: 可少不可多 // let func1 = (a: number, b: string) => {} // let func2 = (x: number) => {} // func1 = func2; // func2 = func
阅读全文
摘要:export default {} // 根据初始值推论 // 相当于 let uname: string = "陈乔恩"; let uname = "陈乔恩"; uname = "徐璐"; // uname = 123; // uname = true; // 相当于 let x: (number
阅读全文
摘要:export default {} // Required<Type> // 构建一个由 Type 的所有属性组成的类型,设置为必填。与 Partial 相反 interface IPerson { name?: string; age?: number; } let res: IPerson =
阅读全文
摘要:export default {} // Record映射类型 // 他会将一个类型的所有属性值都映射到另一个类型上并创造一个新的类型 type Name = "person" | "animal"; type Person = { name: string; age: number } // 注意
阅读全文
摘要:export default {} // 旧的接口 interface IPerson { name: string; age: number; } // 只读 type ReadonlyTest<T> = { // 遍历指定类型所有的key,并添加到当前类型上 // obj = {a: 1} ob
阅读全文
摘要:export default {} // 假如想获取数组里的元素类型。如果是数组则返回数组中元素的类型 // 否则返回这个类型本身 type ID = number[]; type IName = string[]; type Unpacked<T> = T extends IName ? stri
阅读全文
摘要:export default {} // type MyType<T> = T extends any ? T : never; // type res = MyType<string | number | boolean>; // 从 T 中提出可以赋值给U的类型。 Exclude // type
阅读全文
摘要:export default {} // 1.条件类型基本使用 // type MyType<T> = T extends string ? string : any; // type res = MyType<boolean> // 2.函数重载 // interface IName { // n
阅读全文
摘要:export default {} // class Person { // name: string; // age: number; // } // type MyType = Person["name"]; // let a: MyType = "赵韩樱子"; // console.log(a
阅读全文
摘要:export default {} // 创建 let nameSiteMapping = new Map(); // 设置 nameSiteMapping.set("邱淑贞", 1); nameSiteMapping.set("宋茜", 2); nameSiteMapping.set("景甜",
阅读全文
摘要:export default {} // 1.任何类型都可以赋值给unknown类型 let str: unknown; str = 18; str = "张馨予"; str = false; str = [1, 2, 3,]; // 2.不能将unknown类型赋值给其他类型 let val: u
阅读全文
摘要: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 {} // 不使用泛型 // let getArray = (value: number, items: number): number[] => { // return new Array(items).fill(value); // } // // let arr
阅读全文
摘要:export default {} // 演示可能会出现的问题 // function getLength<T>(arr: T): T { // console.log(arr.length); // return arr; // } // getLength<string>("孟子义"); //
阅读全文
摘要:export default {} interface IPersonInfo { name: string; age: number; sex?: string; show(): void; } interface IMusic { music: string } class Person imp
阅读全文
摘要:export default {} abstract class Person { abstract name: string; abstract show(): string; showName() { console.log(this.show()); } } class Student ext
阅读全文
摘要:export default {} class GetNameClass { private _fullName: string = "倪妮"; // 需求:我们就想要在外部进行修改 _fullName 那怎么办? get fullName():string { console.log("我是get
阅读全文
摘要:export default {} class Person { public name: string; protected age: number; private sex: string; constructor(name: string, age: number, sex: string){
阅读全文
摘要:const onAddMenu = useCallback(() => { setCurrentMenu(null); setEditVisible(true); }, []); const onTableChange = useCallback(({ current, pageSize }: Pa
阅读全文
摘要:export default {} // static class StaticTest { static salary: string; static say():void { console.log("我们想要的工资是: " + this.salary); } } StaticTest.sala
阅读全文
摘要:export default {} class Person { name: string; age: number; constructor(name: string, age: number) { this.name = name; this.age = age; } sayHello(): v
阅读全文
摘要:export default {} class Person { name: string; age: number; constructor(name: string, age: number) { this.name = name; this.age = age; } sayHello(): v
阅读全文
摘要:export default {} type VoidFunc = () => void // 在类型别名中指定函数返回值为Void, 我们可以强行给它返回值 这个返回值是有效的 let func1: VoidFunc = function() { console.log("哈哈哈"); retur
阅读全文
摘要:export default {} let userInfo = { name: "邱淑贞", age: 18, song: "恨你太无情", marry: true, show: function() { this.marry = false; } } class Rectangle1 { w:
阅读全文
摘要:export default {} // 不使用函数重载 function add(a: number, b: number) { return a + b; } add(10, 20); function add2(a: string, b: string) { return a + b; } a
阅读全文
摘要:export default {} // 构造函数 var myFunction = new Function("a", "b", "return a*b"); var x = myFunction(4, 3); console.log(x); // 递归函数 function sum(arr: n
阅读全文
摘要:export default {} // 可选参数 const func1:(x: number, y?: number)=> number = function(a, b) { return a; } const func2 = function(a: number, b?: number): n
阅读全文
摘要:export default {} // 匿名函数 const makeMoney = function(salary:number, reward: number): number { return salary + reward; } // 命名函数 function writeCode(hou
阅读全文
摘要:export default {} /* 1.相同点: - 都可以描述属性或方法 - 都允许拓展 2.不同点: - type可以声明基本数据类型,联合类型,数组等; interface只能声明变量 - 当出现使用type和interface声明同名的数据时;type会直接报错;interface会进
阅读全文
摘要:export default {} // - 接口继承就是说接口可以通过其他接口来扩展自己。 // - Typescript 允许接口继承多个接口。 // - 继承使用关键字 extends。 // 单继承 interface IPerson { age: number } interface IN
阅读全文
摘要:export default {} /* 为了使用接口表示函数类型,我们需要给接口定义一个调用签名。 它就像是一个只有参数列表和返回值类型的函数定义。参数列表里的每个参数都需要名字和类型 */ interface ImakeMoney { (salary: number, reward: numbe
阅读全文
摘要:export default {} /* - 定义: 索引签名用于描述那些“通过索引得到”的类型 - 格式: 如`[props: string]:any` - 应用场景: 解决参数问题 */ interface IFullName { firstName: string lastName: stri
阅读全文
摘要:export default {} // 可选属性 ? interface IFullName { firstName: string lastName: string age?: number } let goddessName: IFullName = { firstName: "邱", las
阅读全文
摘要:export default {} /* 接口是什么? 接口是一系列抽象方法的声明,是一些方法特征的集合,这些方法都应该是抽象的,需要由具体的类去实现, 然后第三方就可以通过这组抽象方法调用,让具体的类执行具体的方法 接口也是一种数据类型 格式: interface interface_name {
阅读全文
摘要:export default {} // 类型别名就是给一个类型起个新名字, 但是它们都代表同一个类型 // 第一种 type beautys = "邱淑贞" | "唐嫣" | "迪丽热巴" | "赵露思"; let one:beautys; // one = "赵露思"; // one = 100
阅读全文
摘要:export default {} // 类型断言 // 1.<我们想要它成为的类型>变量名 // 2.变量名 as 我们想要它成为的类型 let str = "世界上最遥远的距离不是生与死, 你是if而我是else, 似乎一直相伴但又永远相离"; // 方式一 // let len = (<str
阅读全文
摘要:namespace A { export const a = 10; } // console.log(A.a); // 嵌套命名空间 namespace B { export const b = 200; export namespace C { export const c = 300; } }
阅读全文
摘要:// JS中的模块 /* 1.默认导入与导出 // 注意点: 这里导入和导出的名字,可以不一致 export default xxx import ooo from "路径" */ /* 1.按需导入与导出 注意点: 这里导入和导出的名字必须一致 export xxx; import {xxx} f
阅读全文
摘要:// 对象混入 // let nameObj = {name: "王楚然"}; // let ageObj = {age: 18}; // // 需求:想让nameObj也拥有 age这个属性 // Object.assign(nameObj, ageObj); // console.log(nam
阅读全文
摘要:export default {}; /* const userInfo: any = undefined; class Test { getName() { try{ return userInfo.name }catch(e) { console.log(e); } } getAge() { t
阅读全文
摘要:// export default {} function paramDecorator(target: any, key: string, index: number) { console.log(target); console.log(key); console.log(index); } c
阅读全文
摘要:export default {} /* function nameDecorator(target: any, key: string) { console.log(target); console.log(key); } class Test { @nameDecorator uname = "
阅读全文
摘要:export default {} function visitDecorator(target: any, key: string, descritor: PropertyDescriptor) { // console.log(target); // console.log(key); // c
阅读全文
摘要:export default {} // 普通方法: target对应的就是 prototype // 静态方法: target对应的就是 类的构造函数 function getNameDecorator(target: any, key: string, desciptor: PropertyDe
阅读全文
摘要:export default {}; /* function testDecorator(constructor: any) { constructor.prototype.uname = "张予曦"; constructor.prototype.show = ():void => { consol
阅读全文
摘要:
阅读全文
摘要:两个数组的内存
阅读全文
摘要:第一部分 求和 求所有的平均数 求那些数比较小
阅读全文
摘要://猜数字小游戏 public class HelloWorld { public static void main(String[] args) { Random r=new Random(); int number= r.nextInt(100)+1; Scanner sc=new Scanne
阅读全文
摘要:优化平方根算法
阅读全文
摘要:跳到外部结束循环
阅读全文
摘要:
阅读全文
摘要:
阅读全文
摘要:
阅读全文
摘要:
阅读全文
摘要:package com.item.demo1; import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { for(int i=1;i<=10;i++){ System.ou
阅读全文
摘要:
阅读全文
摘要:简化写法 jdk12新特性
阅读全文
摘要:设置个default可以有其他位置 case穿透
阅读全文
摘要:
阅读全文
摘要:
阅读全文
摘要:
阅读全文
摘要:
阅读全文
摘要:链式编程
阅读全文
摘要:
阅读全文