While using this way also works, we should not un-necessarily return a function from another function as the inner function will remain in the memory occupying space even after the outer function has finished executing.
You can check out this article to better understand how memory leak can happen when using closures. In filter, map or reduce we provide a callback function as an argument. We don't return a function from a function there.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
While using this way also works, we should not un-necessarily return a function from another function as the inner function will remain in the memory occupying space even after the outer function has finished executing.
could you provide some feedback on this that demonstrates this is a memory leak?
What happens when we pass a "callback" to an Array.prototype.filter|map|reduce ?
What happens when we use libraries like lodash|lodash FP|Rambda and most of the frameworks we use that jump into callbacks from callbacks?
how do they handle those memory leaks? or do they not?
You can check out this article to better understand how memory leak can happen when using closures. In filter, map or reduce we provide a callback function as an argument. We don't return a function from a function there.