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.

EasyTechnical
130 practiced
Compare the semantics and costs of deleting entries from a plain Object (delete obj.key) versus deleting from a Map (map.delete(key)). As an ML engineer optimizing inference throughput, discuss V8/engine implications (hidden classes, inline caches), fragmentation, and whether it's cheaper to reuse objects or recreate them in hot loops.
HardTechnical
114 practiced
Implement an LRUCache class in JavaScript that supports get(key) and put(key, value) in O(1) time. Additionally, support eviction based on an approximate total byte-size budget (evict oldest entries until under budget). Describe how you estimate size for diverse JS values and include a sample implementation that uses Map plus a doubly-linked list for ordering.
HardTechnical
117 practiced
Implement a fast, stable hashCode(obj) in JavaScript for JSON-compatible objects to use as content-based keys in a Map. Requirements: deterministic ordering of object keys, reasonably fast for small-to-medium objects, and low collision probability for typical feature payloads. Provide code using a canonicalization step and a fast non-cryptographic hash (e.g., FNV-1a or xxhash pseudocode), and discuss collision handling.
MediumTechnical
79 practiced
You're seeing a memory leak in a Node.js service where a long-lived Object cache grows until OOM after running for days. Outline debugging steps using heap snapshots and flame charts, then implement a migration sketch that uses WeakMap for caching per-request object derivatives where keys are request objects. Provide code that demonstrates replacing an Object cache with a WeakMap when keys are objects, and explain limitations if keys are primitives.
EasyTechnical
96 practiced
Property descriptors allow fine-grained control over object properties in JavaScript. As an ML engineer, how would you use property descriptors to create read-only feature metadata fields in a feature config object? Explain configurable/enumerable/writable/get/set and provide a short code sample showing how to make a 'featureName' property read-only while keeping other properties writable.

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.