Every time you call const df = debounce(f) it will create new closure, which contains inside of it anonymous function (return x => {) which will be returned (and assigned to df in this case). But after this you use df which is one instance of the function. If you call const df2 = debounce(f) it will create another closure and another anonymous function.
It works the same way as if you would assign variable. Consider following code example const test = () => [] it will create new instance of array every time you call it (test() !== test()).
Every time you call
const df = debounce(f)
it will create new closure, which contains inside of it anonymous function (return x => {
) which will be returned (and assigned todf
in this case). But after this you usedf
which is one instance of the function. If you callconst df2 = debounce(f)
it will create another closure and another anonymous function.It works the same way as if you would assign variable. Consider following code example
const test = () => []
it will create new instance of array every time you call it (test() !== test()
).Did I answer your question?
Definately thank you - just thought there would be some kind of optimization going on inside the engine like memoization.