04 2023 档案
手写防抖节流函数
摘要:防抖函数 function debounce(fn, t) { let timeId return function () { // 如果有定时器就清除 if (timeId) clearTimeout(timeId) // 开启定时器 200 timeId = setTimeout(functio
阅读全文
手写一个深拷贝
摘要:function deepClone(obj) { if(typeof obj !='object') return object // 1、建立新容器 var temp = array.isArray(obj)?[]:{} // 2、 通过遍历将原有数组的值循环出来放到新建立的容器上 for (l
阅读全文
请封装⼀个⽅法,将以下树形数据转换成期望的格式
摘要:转化前 const list = [ {id:1}, {pid:1,id:2}, {id:3}, {pid:3,id:4}, {pid:4,id:5} ] 转化后 [{ id:1, children:[{ pid:1, id:2 }] }, { id:3, children:[{ pid:3, id
阅读全文
浙公网安备 33010602011771号