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.

HardTechnical
0 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.
EasyTechnical
0 practiced
Write a JavaScript function dedupePreserveOrder(arr) that removes duplicates from an array of primitive feature names while preserving the first occurrence order. Example:
Input: ['age','gender','age','location']Output: ['age','gender','location']
Requirements: use ES6+, aim for O(n) time and O(n) additional memory, and avoid modifying the input array. Include a short usage example in your answer.
MediumTechnical
0 practiced
Discuss approaches to enforce immutability on nested data structures in JavaScript used in ML pipelines: Object.freeze, shallow vs deep freeze, Immer/structural-sharing libraries, and immutable-js. For each, describe developer ergonomics, runtime performance, memory footprint, and suitability for making fast model snapshots for A/B testing.
HardTechnical
0 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.
EasyTechnical
0 practiced
Implement deepClone(value) in JavaScript that clones JSON-compatible values (objects, arrays, primitives) but throws on encountering functions, symbols, or circular references. The function should preserve arrays and plain objects but not prototypes. Show a few example inputs/outputs and ensure circular references are detected and reported.

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.