Memoization

Chris Laughlin

Who am I?

JavaScript Developer @Rapid7

 

Open source contributor   

 

All round JavaScript nerd

Jack of all trades, master of none

History 

  • Coined by Donald Michie in 1968
  • Grew in popularity with functional programming (Haskell/Erlang)
  • Mentioned in JavaScript: The good parts 

Basics

  • Memoize === cache 
  • Function wrapping 
  • Performance improving 

fibonacci

cache?

Memoize Pattern

Benchmarks

Cons

  • Can't be used with non-pure functions
  • Functions that get data that has to always be up-to-date 
  • Functions with large parameters or functions as params 

Pros

  • Reduced execution time
  • Encourages functional programming
  • MAKES EVERYTHING FAST!

But wait there is more!

Memoize React component?

questions?......

memoization

By Chris Laughlin

memoization

  • 1,057