摘要: function addMethod(obj,name,fun){ const old=obj[name]; obj[name]=function(...args){ if(args.length fun.length){ return fun.apply(this,args); }else if( 阅读全文
posted @ 2026-01-22 17:27 howhy 阅读(2) 评论(0) 推荐(0)
摘要: function createFetchWithTimeout(timeout=2000){ return function (url,options){ return new Promise((resolve,reject)=>{ const singalController=new AbortC 阅读全文
posted @ 2026-01-22 14:19 howhy 阅读(1) 评论(0) 推荐(0)
摘要: //c.jsfunction processTasks(...tasks){ let isRunning=false; const result=[]; let i=0; return { start(){ return new Promise(async (resolve,reject)=>{ i 阅读全文
posted @ 2026-01-20 16:31 howhy 阅读(1) 评论(0) 推荐(0)
摘要: class TaskParallel{ constructor(parallelcount=2){ this.parallelcount=parallelcount; this.tasks=[]; this.runningCount=0; } add(task){ return new Promis 阅读全文
posted @ 2026-01-20 15:05 howhy 阅读(3) 评论(0) 推荐(0)
摘要: const obj=[ {a:1,b:2}, {b:2,a:1}, {a:1,b:2}, {a:3,b:{c:11,d:4}}, {a:3,b:{d:4,c:1}} ] const newArr=[...obj]; function isObject(obj){ return obj!==null 阅读全文
posted @ 2026-01-20 13:57 howhy 阅读(2) 评论(0) 推荐(0)
摘要: function createProxy(value=0){ return new Proxy({},{ get(target,prop){ if(prop Symbol.toPrimitive){ return ()=>value; }else{ return createProxy(value+ 阅读全文
posted @ 2025-12-31 15:46 howhy 阅读(36) 评论(0) 推荐(0)
摘要: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document< 阅读全文
posted @ 2025-12-31 10:05 howhy 阅读(39) 评论(0) 推荐(0)
摘要: const users=[ {name:'zhangsan',age:23,gender:'male'}, {name:'lisi',age:20,gender:'female'}, {name:'wangwu',age:18,gender:'male'}, {name:'zhaohu',age:1 阅读全文
posted @ 2025-12-30 10:31 howhy 阅读(21) 评论(0) 推荐(0)
摘要: // 实现防抖函数 function debounce(fn, delay, immediate = false) { // 实现 let timer=null; let result=null; return function(...args){ if(timer){ clearTimeout(t 阅读全文
posted @ 2025-12-29 16:15 howhy 阅读(17) 评论(0) 推荐(0)
摘要: // 实现 instanceof 操作符 function myInstanceof(left, right) { // 实现 if(typeof right!=='function' || right.constructor null){ throw new Error('right must b 阅读全文
posted @ 2025-12-29 14:24 howhy 阅读(11) 评论(0) 推荐(0)