Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Track the timestamp of the last execution. On each call, check whether enough time has elapsed since the last run. If so, execute the function and update the timestamp; otherwise, skip the call. Use apply to preserve context.
Comparing Date.now() against the last execution time guarantees the function runs at most once per interval, smoothing rapid event streams like scroll or resize.
Updated Mar 2026