Discussion of Memoization
September 7, 2011 in Test-Driven JavaScript Development
So, today we were visiting about memoization in JavaScript . This is basically the concept of caching the arguments and results of a function call as an object in the function.
I mentioned an article by John Hann regarding memoization and you can find it here:
http://unscriptable.com/index.php/2009/05/01/a-better-javascript-memoizer/.
The article has an interesting discussion of the use of the function instance to cache the results or to use anonymous function calls to encapsulate the result variable. This all has to do with memory and performance optimization and will require a bit of experimenting to fully understand.
Johnn is referencing a presentation given by Stoyan Stefanov from Yahoo at JSConf in 2009. I went and found the presentation he was talking about and you can find it here:
http://www.slideshare.net/stoyan/high-performance-kick-ass-web-apps-javascript-edition
The slide where he starts talking about memoization is slide 79.
Anyway, let’s discuss.
Chad said on September 7, 2011
A key line from the TDDJS book:
“Memoization is a technique that can be employed to avoid carrying out expensive operations repeatedly, thus speeding up programs.”
Thomas said on September 7, 2011
Indeed. That seems to be the consensus of the concept and it’s biggest value add.