nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

TOPIC OVERVIEW

javascript/Memoisation

Trading memory for speed by remembering what a function already computed.

10 QuestionsAdvancedMedium Priority ~11 min read

Memoization caches the result of a function call keyed by its arguments, so calling it again with the same arguments returns the cached value instantly instead of recomputing it. It only works correctly for pure functions — if a function's output can change for the same input (depends on external state, time, or randomness), caching it produces stale, incorrect results, which is the most common mistake in naive memoization implementations.

The tricky part in practice is the cache key. Primitive arguments are easy to key with something like JSON.stringify(args), but that breaks down for objects (key order isn't guaranteed, and deep equality isn't free to check) and doesn't scale for functions with many possible argument combinations, since the cache grows unbounded unless you add eviction. Using a Map or WeakMap instead of a plain object avoids prototype pollution issues and, with WeakMap, lets cached entries for object keys be garbage collected once nothing else references them.

What you'll walk away knowing

Why memoization only works safely for pure functions, and what breaks it
How to key a cache for primitive arguments versus object arguments
Why Map or WeakMap is a better cache store than a plain object, and when WeakMap specifically helps
Tradeoffs of memoization: unbounded cache growth, and when a real caching strategy (LRU, TTL) is needed instead
1What is memoisation?Intermediate
All Topics
1
Basics
Data Types
Functions
Objects
2
Engine
JIT
V8
Event Loop and Runtime
Concurrency and Threading
Bytecode and Parsing
Execution Context
Garbage Collector
3
this
Call Apply Bind
Closure
Error Handling
4
String Operations
Array Operations
Iterator and Generator
Modules
5
Events
Promises
Web Workers
Web Sockets
6
Functional Programming
Currying
Higher Order Functions
Memoisation
7
ES6 Classes
ES6
PWA
Web Assembly
Browser APIS
8
Security
Code
Polyfills
Sharethis topic

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.