Implement a memoize function that caches the results of function calls to avoid unnecessary re-computation.
A standard implementation often relies on simple serialization, but you must ensure it does not break down with special JavaScript types or context binding. Your implementation must respect the original function's contract completely.
fn and return a memoized version of it.this context.undefined vs null, NaN, Infinity).Write memoize in the editor, then run the test cases on the right. Case 1 checks
that repeated calls hit the cache; Case 2 checks that look-alike values stay
distinct; Case 3 checks that this survives. Add your own case with + Add to
probe an edge you're unsure about.
function memoize(fn) { // Your implementation here }
Test Code
Enter JavaScript that runs after your solution. It should return a value or a Promise.