摘要: // 实现防抖函数 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)
摘要: class Singleton { // 1. 使用私有静态属性 static #instance = null; // 2. 防止直接 new constructor() { if (Singleton.#instance) { throw new Error('Use getInstance() 阅读全文
posted @ 2025-12-29 14:06 howhy 阅读(40) 评论(0) 推荐(0)