⚡
Throttle
Throttle어려움 함수 +40pts
Problem
Write a throttle function that limits how often a function can be called.
Examples
Input:
throttle(fn, 100)Output:
100ms마다 최대 1번만 실행Explanation
이 문제는 **스로틀(throttle)** 패턴을 구현하여 함수 실행 빈도를 제한하는 방법을 학습합니다. ## 핵심 개념: 스로틀 스로틀은 일정 시간 동안 최대 한 번만 함수가 실행되도록 제한합니다. ### 접근 방법 ```javascript function throttle(fn, limit) { let lastCall = 0; return function(...args) { const now = Date.now(); if (now - lastCall >= limit) { lastCall = n...
View detailed explanation →Key Concepts
스로틀 Date.now 실행 빈도 제한 성능 최적화
Time: O(1) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.