随笔分类 - 前端歌谣ts-学习-2022
前端ts-学习-2022
摘要: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 {}; /* 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
阅读全文
摘要: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
阅读全文