Categories
JavaScript Answers

How to fix Lodash debounce not working in anonymous function with JavaScript?

Spread the love

Sometimes, we want to fix Lodash debounce not working in anonymous function with JavaScript.

In this article, we’ll look at how to fix Lodash debounce not working in anonymous function with JavaScript.

How to fix Lodash debounce not working in anonymous function with JavaScript?

To fix Lodash debounce not working in anonymous function with JavaScript, we call the function that debounce returns.

For instance, we write

_.debounce(debounceIt, 500, false)();

to call debounce with the debounceIt and the debounce interval to return a debounced function.

Then we call it immediately with () at the end.

Conclusion

To fix Lodash debounce not working in anonymous function with JavaScript, we call the function that debounce returns.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *