总要热爱点什么吧,不然生活多无趣。
3、路由 react-router-dom V6 用法剖析实现客户端以及服务端路由层面的同构React Router v6Redux Recoil Mbox实现一些自定义hooksWebpack babel vite Pnpm monorepoabortController 1、如何使用、二次封装2、状态管理工具的分类和比较,实际业务中如何选择Context API数据如何获取和设置状态的基本值如何管理数据异步工作流如何处理数据之间的联动即派生状态 (触发A的更新 联动B的更新)useContext + useReucer 数据量大需要创建大量context,对context state的变更会导致所有使用该contextre-redner,即时使用的不是修改的那个state值,可以采用useMemo来解决,但是仍存在一定成本单向数据流:redux react-redux大量模板代码、状态量大,需要把所有reducer跑一遍,潜在性能问题 响应式:MboxMbox对全局state做了一层代理,监听state变化,自动更新计算属性,响应状态变化的一些操作;所以mobox可以对
function getData(val) { return new Promise(resolve => { setTimeout(() => { resolve(val * 2) }, 1000); }) } async function get() { const data1 = await getData(1); const data2 = await getData(data1); return `success: ${data2}`; } get().then(res => { console.log('%c [ res ]-18', 'font-size:13px; background:pink; color:#bf2c9f;', res) }) function* getGen() { const data1 = yield getData(1) const data2 = yield getData(data1); return `success: ${data2}`; } v
基础篇实现Object.create实现instanceof方法实现new关键字拦截构造函数调用实现继承简单实现Promise防抖函数节流函数实现类型判断函数实现call函数实现apply函数实现bind浅拷贝深拷贝实现Object.assign简单实现async/await中的async函数实现一个Object.freeze用ES5实现一下map和reduce函数场景篇0.1+0.2问题大数相加解决[415.字符串相加]大数相乘[43.字符串相乘]数组乱序输出数组去重复(7种方法)数组扁平化flatten(6种方法)对象扁平化flatObj数字千分位分割js下划线转驼峰处理Hex转RGB的方法实现模版字符串解析数组转树形结构的三种方法获取URL中的参数进阶篇:请求并发控制带并发限制的promise异步调度器实现lazy链式调用: person.eat().sleep(2).eat()函数柯里化lazy-load实现实现简单的虚拟dom实现SWR 机制实现一个只执行一次的函数LRU 算法实现:LRU(Least recently used,最近最少使用)算法根据数据的历史访问记录来进行
1、前端如何实现请求并发控制20个请求需要发送,由于某些原因,需要我们将同一时刻的并发请求数量控制在3个以内,并且需要尽快拿到响应结果/** * 前端如何实现请求并发控制 * * 实现一个并发请求函数concurrencyRequest(urls, maxNum),要求如下: * • 要求最大并发数 maxNum * • 每当有一个请求返回,就留下一个空位,可以增加新的请求 * • 所有请求完成后,结果按照 urls 里面的顺序依次打出(发送请求的函数可以直接使用fetch即可) */ const concurrencyRequest = (urls: string[], maxNum: number) => { return new Promise((resolve) => { const results: Response[] = [], _maxReqNum = urls.length; let _records = maxNum; const request = (idx) => { con
1、确定单调栈的递增/递减方向2、每次移动保证当前值与栈顶数据的实时更新递增方向: 当遍历元素小于或等于栈顶元素时,入栈,调整栈顶元素为最新移入的最小值,依次遍历,当获取大值时,出栈顶,计算差值,直到栈顶元素大于遍历当前元素最新值,最新值入栈,重复此过程,直到遍历完成 function dailyTemperatures(temperatures: number[]): number[] { const result = new Array(temperatures.length).fill(0), st = [0]; for(let i = 1; i < temperatures.length; i++) { if(temperatures[i] <= temperatures[st[st.length - 1]]) { st.push(i); } else { while(st.length >0 && temperatures[i] > t
李优秀同学
待会去码头整点薯条