JS 基本
Debounce
function debounce(fn, delay = 1000) {
let timer = null
return function () {
timer && clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(this, arguments)
timer = null
}, delay)
}
}
const c = debounce(() => {console.log('test')})
// 使用:呼叫多次 c()Throttle
Call, Apply, Bind
深拷貝、淺拷貝
Last updated