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
0 practiced
Given a very large array (e.g., 10 million) of feature objects {featureName, value}, implement an optimized function computeSumByFeature(list) in JavaScript that returns a Map of featureName -> sum. Discuss micro-optimizations (plain for-loops, local variable caching, avoiding temporary allocations) and why they matter for large data in Node.js.
HardTechnical
0 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.
EasyTechnical
0 practiced
You have a feature object and a Map mapping feature names to indices. Implement two short code snippets (in JavaScript) that iterate over the object and over the Map to produce an Array aligned with the Map's insertion order containing values for each Map key (undefined if missing). Explain differences in enumeration order and why a Map might be more reliable for preserving intended order.
MediumTechnical
0 practiced
Write a function flattenObject(obj, options) in JavaScript that converts a nested object into a flat object with dot-notated keys. Example:Input: { user: { age: 30, address: {city: 'NY'} } }Output: { 'user.age': 30, 'user.address.city': 'NY' }Options should allow choosing how to treat arrays (include indices like 'arr.0' or join arrays). Handle collisions (like both 'a.b' and 'a.b.c') in a reasonable way and document your choice.
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 ContinueJoin thousands of developers preparing for their dream job.