Memoization in JavaScript

What is memoization? It is a concept in JavaScript used to cache results of expensive or long-run operations so that we can reuse these results without having to rerun the operation.

How does memoization work? Let’s imagine that we are using the Google Maps API to find the coordinates of a city. Without memoization, each time there is a request to find the coordinates for ‘Los Angeles,’ we would need to make an HTTP request to the Google Maps API. HTTP requests can be unpredictable or slow. With the concept of memoization, we store/cache the results of the first request so we can…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store