01JS↗
Debounce with Immediate Option
Debounce function with leading edge (immediate) and trailing edge options
function debounce(func, wait, options = {}) {
const { leading = false, trailing = true, maxWait } = options;
let timeoutId, lastCallTime, lastInvokeTime, result;
let lastArgs, lastThis;#debounce#performance
medium