Toggle navigation
亻中 阝日
社区
VA伐木累
Proxy
JSON
BASE64
MyGit
登录
注册
×
登录
邮箱
密码
忘记密码?
函数 节流 和 防抖
•发布于
•作者
liuzy
•658 次浏览
•来自
技术
```js /** * 生成节流函数 * @param {*} fn * @param {*} delay */ const throttle = (fn, delay = 100) => { let timer = null let _args = null return function(...args) { _args = args if (timer) return timer = setTimeout(() => { timer = null fn.apply(this, _args) }, delay) } } /** * 生成防抖函数 * @param {*} fn * @param {*} delay */ const debounce = (fn, delay = 100) => { let timer = null let _args = null return function(...args) { _args = args if (timer) clearTimeout(timer) timer = setTimeout(() => { timer = null fn.apply(this, _args) }, delay) } } ```
0 回复
作者
liuzy
积分: 841
“ 黑眼圈圈男 ”
无人回复话题
SonarQube 9.4 + PostgreSQL
shell倒计时
日常网络巧技
使用ssh创建socks5代理服务
NodeJS集群demo
作者其他话题
SonarQube 9.4 + PostgreSQL
shell倒计时
日常网络巧技
使用ssh创建socks5代理服务
NodeJS集群demo
回到顶部
友情链接:
JFinal
©2015 Powered by
jfinalbbs
沪ICP备15012258号