diff --git a/snippets/throttle.md b/snippets/throttle.md index b49a07950..b06a2df8a 100644 --- a/snippets/throttle.md +++ b/snippets/throttle.md @@ -8,6 +8,7 @@ Creates a throttled function that only invokes the provided function at most onc Use `setTimeout()` and `clearTimeout()` to throttle the given method, `fn`. Use `Function.prototype.apply()` to apply the `this` context to the function and provide the necessary `arguments`. Use `Date.now()` to keep track of the last time the throttled function was invoked. +Use a variable, `inThrottle`, to prevent a race condition between the first execution of `fn` and the next loop. Omit the second argument, `wait`, to set the timeout at a default of 0 ms. ```js @@ -41,4 +42,4 @@ window.addEventListener( console.log(window.innerHeight); }, 250) ); // Will log the window dimensions at most every 250ms -``` \ No newline at end of file +```