What is Memoization anyway?
The ability to return the previously calculated value without recalculating them, on receiving same set of...
For further actions, you may consider blocking this person and/or reporting abuse
I love this. When I was first really digging into JavaScript, I worked through re-implementing everything in Underscore.js and found it super valuable.
_.once
and_.memo
were pretty hard and really showed how scope and closures were different in JS than I'd realized.Glad it helped :)
What would be a potential context/use case for this optimization in the wild?
The summation function here is so simple. But consider you are making an expensive operation instead of just sum.In that case if you already have a cached value from previous call it becomes handy.
Even react.memo should be doing something similar to this(But handling all limitations which my solution had)
It's clever, I love this, nice work dude!
😅✌️✌️