给出定义与实现,并说明搜索输入用哪个。
function debounce(fn, wait) {
let t;
return (...a) => { clearTimeout(t); t = setTimeout(() => fn(...a), wait); };
}
function throttle(fn, wait) {
let last = 0;
return (...a) => {
const now = Date.now();
if (now - last >= wait) { last = now; fn(...a); }
};
}题目与答案就在本页;收藏、批注和错题重练在应用内