Avatar of Thomas

by

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.

 

 

 

 

 

2 responses to Discussion of Memoization

  1. 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.”

Leave a reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>