摘要: 学习资源 手写节流函数【渡一教育】 完整代码 function throttle(fn, wait) { let lastTime = null; return function (...args) { const now = Date.now(); if (lastTime null || now 阅读全文
posted @ 2025-02-16 22:12 lao-jiawei 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 学习资源 什么是闭包?是否会造成内存泄漏?【渡一教育】 什么是闭包? 在一个函数的环境中,闭包= 函数+词法环境 function m(){ var a=1; function sub(){ } } 即便sub为空函数,都是闭包。 不是所有闭包都会造成内存泄露——如果函数后续需要用到,就不算内存泄露 阅读全文
posted @ 2025-02-16 21:13 lao-jiawei 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 完整代码 Function.prototype.myBind = function (ctx, ...args) { const fn = this; return function (...resArgs) { if (new.target) { return new fn(...args, .. 阅读全文
posted @ 2025-02-16 20:19 lao-jiawei 阅读(3) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示
主题色彩