// 防抖const debounce = (fn, delay) => {let timer = nullreturn function () {const args = argumentsclearTimeout(timer)timer = setTimeout(() => {fn.apply(this, args)}, delay)}}// 节流const throttle = (fn, delay) => {let timer = nullreturn function () {const args = argumentsif (timer) returntimer || fn.apply(this, args)timer = setTimeout(() => {timer = null}, wait)}}
