摘要: function formatDate(date, format='date') { if(typeof format 'function'){ format=format(); } if(typeof format !=='string'){ return new TypeError('forma 阅读全文
posted @ 2025-12-05 16:43 howhy 阅读(0) 评论(0) 推荐(0)
摘要: function Foo(a,b){ console.log(a==arguments[0],b==arguments[1]); console.log(a,b); a='44'; b='555'; console.log(a==arguments[0],b==arguments[1]); //若F 阅读全文
posted @ 2025-12-03 14:47 howhy 阅读(2) 评论(0) 推荐(0)
摘要: 1、原始转数字: Boolean转数字:true :1 false: 0 null: 0 undefined: NaN []: 0 {}:NaN ' \r\t\n ': 0 ' 123\t ' :123 'anc':NaN 2、所有转Boolean: 这几种情况是false:0 null undef 阅读全文
posted @ 2025-12-03 14:00 howhy 阅读(3) 评论(0) 推荐(0)
摘要: function myNew(constructor, ...args) { // 参数验证 if (typeof constructor !== 'function') { throw new TypeError('myNew: First argument must be a function' 阅读全文
posted @ 2025-11-26 15:53 howhy 阅读(5) 评论(0) 推荐(0)
摘要: class MyPromise{ constructor(executor){ this.state='pending'; this.value=undefined; this.reason=undefined; this.onFulfilledCallbacks=[]; this.onReject 阅读全文
posted @ 2025-11-26 11:45 howhy 阅读(3) 评论(0) 推荐(0)
摘要: 1. Promise.all() 概念 等待所有 Promise 成功,或者任何一个 Promise 失败。 2. Promise.race() 概念 返回第一个 settled(完成或拒绝)的 Promise。 3. Promise.any() 概念 返回第一个成功的 Promise,如果所有 P 阅读全文
posted @ 2025-11-26 10:34 howhy 阅读(4) 评论(0) 推荐(0)
摘要: let _curDependFun=null; class dependCls{ constructor(){ this.dependFuns=new Set(); } depend(){ _curDependFun && this.dependFuns.add(_curDependFun); } 阅读全文
posted @ 2025-11-26 09:34 howhy 阅读(3) 评论(0) 推荐(0)
摘要: + 运算符的双重角色 JavaScript 中的 + 运算符有两个主要功能: 数字加法 字符串拼接 类型转换规则 1. 基本规则 当使用 + 运算符时,JavaScript 遵循以下优先级: 如果任一操作数是字符串,进行字符串拼接 否则,尝试将两个操作数转换为数字进行加法运算 对象到原始值的转换过程 阅读全文
posted @ 2025-11-26 09:24 howhy 阅读(5) 评论(0) 推荐(0)
摘要: function curry(func) { return function curried(...args) { const context = this; // 如果参数数量足够,直接执行原函数 if (args.length >= func.length) { return func.appl 阅读全文
posted @ 2025-11-25 11:49 howhy 阅读(4) 评论(0) 推荐(0)
摘要: 节流是指连续触发事件但在 n 秒内只执行一次函数。 使用场景 滚动加载更多 鼠标移动事件 按钮频繁点击 游戏中的按键处理 function throttle(func, delay, options = {}) { let timeoutId = null; let lastTime = 0; co 阅读全文
posted @ 2025-11-25 11:35 howhy 阅读(5) 评论(0) 推荐(0)