Memorization in JS
Memorization in JS
JS
Cache function result
using Memoization
@coder_aishya
01
Input Output
Memonizer function
@coder_aishya
02
What is Memoization ?
Memoization is an optimization technique
where expensive function calls are
cached(stored) such that the result can be
immediately returned the next time the
function is called with the same arguments
@coder_aishya
03
Cache
A cache is just a temporary data store(JS
object) that stores data in order to serve
future requests for that data more quickly.
Note: Browser cache need not be applied in
this scenario.
@coder_aishya
04
Steps:
define a function using ES6
@coder_aishya
05
@coder_aishya
06
Example
Create a memoize function that remembers
previous inputs and stores them in cache so
that it won’t have to compute the same
inputs more than once. The function will take
an unspecified number of integer inputs and
a reducer method.
@coder_aishya
07
Memonizer function
@coder_aishya
08
@coder_aishya
Follow me for more
aishwarya-dhuri
coder_aishya