当前位置:网站首页>简单手写debounce函数
简单手写debounce函数
2022-06-28 05:40:00 【Joey_Tribiani】
function debounce(cb, timeout = 300) {
// 闭包一个上次触发时间
let lastEmitTime;
return function () {
// 每次调用更新上次触发时间
lastEmitTime = new Date().valueOf();
setTimeout(() => {
// 设置的timeout时间过后去比较最后一次调用时间是否已经是超过了设置的timeout 超过了就调用callback
const currentTime = new Date().valueOf();
if (currentTime - lastEmitTime >= timeout) {
cb(...arguments);
}
}, timeout);
};
}
边栏推荐
- Bidirectional level conversion circuit
- 猿粉猿动力-开发者活动袭!
- Data warehouse: DWS layer design principle
- qtcanpool 知 07:Ribbon
- [C language practice - printing hollow square and its deformation]
- Blog login box
- 【MYSQL】所有查询表中有2千万数据--sql如何优化
- 密码学笔记
- 2022 new version NFT source code source code of China meta universe digital collection art trading platform
- Gee learning notes 3- export table data
猜你喜欢

codeforces每日5题(均1700)

Filecoin hacker song developer competition

Solution of dam safety automatic monitoring system for medium and small reservoirs

Animation de ligne
![A full set of excellent SEO tutorials worth 300 yuan [159 lessons]](/img/d7/7e522143b1e6b3acf14a0894f50d26.jpg)
A full set of excellent SEO tutorials worth 300 yuan [159 lessons]

【JVM】——JVM中内存划分

RL 实践(0)—— 及第平台辛丑年冬赛季【Rule-based policy】

5G网络整体架构

Gee learning notes 3- export table data

JSP connecting Oracle to realize login and registration
随机推荐
Mysql-16-subquery
【MYSQL】所有查询表中有2千万数据--sql如何优化
Detailed usage configuration of the shutter textbutton, overview of the shutter buttonstyle style and Practice
独立站卖家都在用的五大电子邮件营销技巧,你知道吗?
若依实现下拉框
线条动画
Animation de ligne
数据仓库:分层设计详解
Why does the company choose cloud database? What is its charm!
How does guotaijun charge for safe varieties? Let's talk about the futures account opening process
北斗三号短报文终端在大坝安全监测方案的应用
数据中台:数据治理的七把利剑
【C语言练习——打印空心正方形及其变形】
Filecoin hacker song developer competition
If a programmer goes to prison, will he be assigned to write code?
numpy. reshape, numpy. Understanding of transfer
[untitled] drv8825 stepping motor drive board schematic diagram
JSP connects with Oracle to realize login and registration (simple)
Video tutorial on website operation to achieve SEO operation [21 lectures]
Blog login box