I came across this piece of code ... where args
is interpreted to fn
args object
... this is really confusing for me, and I couldn't get it
function memoize(fn) {
return function(...args) {
fn.apply(this, args);
}
}
How does the inner function understand that args
passed to it belongs to fn
Edit
Now I get it ...
This wrapper function should be called this way const fastfunction = memoize(slowfunction);
... and the returned function (the inner-function) 'd be fastFunction
which should be called with a set of args... and ...args
is kinda a placeholder for these args