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.

MediumTechnical
93 practiced
Implement an LRU cache class in JavaScript using Map with methods get(key) and put(key, value). The cache should have a fixed capacity and update recency on get operations. Explain why Map can be used to track recency and how you would evict the least recently used item.
HardTechnical
91 practiced
Implement serialize(obj) and deserialize(s) in JavaScript to convert nested structures containing Map, Set, Symbol keys, and typical primitives into a JSON-friendly string and back. Include an encoding scheme for Map/Set and for non-string keys, mention how you would handle circular references, and discuss limitations.
MediumTechnical
89 practiced
Explain differences and performance implications among Object.keys, Object.getOwnPropertyNames, Object.getOwnPropertyDescriptors, for...in loops, and Reflect.ownKeys when enumerating or copying properties, including Symbol and non-enumerable properties. Recommend a safe enumeration strategy for reading configuration objects.
HardTechnical
91 practiced
Implement a robust deepEqual(a, b) in JavaScript that compares primitives, Objects, Arrays, Dates, RegExps, Maps, Sets, and TypedArrays and correctly handles cyclic references. Describe how you handle order-insensitive collections (Set/Map) and how to compare typed arrays efficiently.
EasyTechnical
86 practiced
Implement in JavaScript a function isOwn(obj, key) that returns true if key is an object's own property (not inherited). The function should correctly handle string and Symbol keys and avoid throwing when obj is null or undefined.

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.