DEV Community

Discussion on: JavaScript: Memoization

Collapse
 
markfilan profile image
markfilan

Memoization is an optimization technique that allows an increase in the performance of a program by storing the results of some expensive function so that we don’t need to call that function when the same inputs are given. It does this by storing computation results in cache, and retrieving that same information from the cache the next time it's needed instead of computing it again. The concept of Memoization in Javascript is backed by two main sub-concepts: Closure and High order function. In JavaScript, closures are generated every time a function is created and it allows you access to the domain of the outer function from the inner function. A high order function accepts another function as an argument or returns a function as its output.

This technique is specially useful when it comes to dynamic programming . A memoized function is usually faster because if the function is called subsequently with the previous value(s), then instead of executing the function, would be fetching the result from the cache .

net-informations.com/js/default.htm