InterviewStack.io LogoInterviewStack.io

Basic Data Structures (Objects, Maps, Sets) Questions

Understand how objects work in JavaScript including prototypal inheritance and property descriptors. Know when to use Maps vs Objects and Sets vs Arrays. Understand the performance characteristics of different data structures. Be comfortable with nested data structures and how to manipulate them efficiently.

MediumSystem Design
71 practiced
Design an in-memory feature cache for a Node.js microservice that must hold ~100k keys within ~1GB of memory and serve 10k req/s. Describe architecture choices: Map vs Object, eviction policy (LRU/TTL), sharding across CPU cores, persistence/fallback to disk, serialization for warm restarts, and how to monitor and instrument cache health. Explain trade-offs and failure modes.
HardTechnical
85 practiced
Implement serialize(obj) and deserialize(str) in JavaScript that preserve Map and Set types within nested structures. Your serializer should convert Maps and Sets into JSON in a way that can be reversed by deserialize into original types. Do not handle functions; throw on circular references. Provide example round-trip behavior for nested containers.
HardTechnical
83 practiced
Many samples share the same feature schema (same keys) but different values, causing duplicated key strings and objects across millions of instances. Propose and demonstrate a memory-optimization pattern in JavaScript (flyweight/prototype sharing) that reduces per-instance memory by sharing a common prototype for default keys and only storing differing values as own properties. Provide illustrative code and discuss trade-offs (GC, mutation safety, debugging complexity).
EasyTechnical
70 practiced
Write a JavaScript function freezeFeature(obj, paths) that takes an object and an array of key paths (e.g., ['name', 'metadata.createdAt']) and sets those properties to be non-writable and non-configurable using Object.defineProperty. The function should support nested paths and leave other properties mutable. Show an example of usage and verify that JSON.stringify still includes frozen keys.
MediumTechnical
95 practiced
Design a benchmarking harness to compare Map vs Object lookups with 1 million entries in Node.js. Describe how you'd implement warm-up, measurement (ops/sec, median latency, max latency), memory consumption, GC events, and how you'd control for noise (process isolation, repeated runs). Provide pseudocode for the harness and describe how to interpret the results for production decisions.

Unlock Full Question Bank

Get access to hundreds of Basic Data Structures (Objects, Maps, Sets) interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.