SpinTheMic
Pro

Interview practice question

Implementing an LRU cache in JavaScript

Frontend Engineering · JavaScript Core · Experienced

Implement an LRU cache with a fixed capacity in JavaScript. How would you do it efficiently?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Map preserves insertion order.
  • get: delete and re-insert to mark recent.
  • set: insert, evict oldest (first key) if over capacity.
  • O(1) operations.
  • Consider TTL/size by bytes.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics