debounce
디바운스(DeBounce)
프로그래밍에서의 디바운싱
디바운싱 사용 예시
function debounce(func, wait) {
let timeout;
return function(...args) {
const context = this;
clearTimeout(timeout);
timeout = setTimeout(() => {
func.apply(context, args);
}, wait);
};
}
// 로그 기록 함수
function logResizeEvent() {
console.log('Window resized!');
}
// 디바운스 적용
const debouncedLog = debounce(logResizeEvent, 300);
// resize 이벤트에 적용
window.addEventListener('resize', debouncedLog);쓰로틀링이란?
쓰로틀링 예시
디바운스와 쓰로틀링 차이점 요약
디바운스 (Debounce)
쓰로틀링 (Throttling)
리딩 엣지 VS 트레일링 엣지
Last updated