DEV Community

Discussion on: Understanding Memoization In JavaScript

unalo_baayriyo profile image
Kamlesh Nehra Author

Here is the example -
const multiplyTwo = (n) =>(n*2)
const memoizerHocMuultiplyTwo = memoizerHoc(multiplyTwo);
console.log(memoizerHocMuultiplyTwo(3)); // return calculated result
console.log(memoizerHocMuultiplyTwo(3)); // return cached result

Thanks for pointing out the missing bracket.

diogorodrigues profile image
Diogo Rodrigues • Edited

Thank you!!! But in this case the examples are different, because in the first one you created a factorial of a number using recursion function. I didn't realize this difference before; I was thinking to pass a recursive function in the second example. Sorry for my bad.