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
0 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.
EasyTechnical
0 practiced
You're a Machine Learning Engineer building a Node.js microservice that loads JSON feature configurations into memory. Explain how JavaScript objects implement property lookup and prototypal inheritance and why that matters for feature access. In your answer:1) Define own vs inherited properties and how lookup proceeds up the prototype chain.2) Show a short code example demonstrating prototype inheritance and property shadowing.3) Explain pitfalls (e.g., prototype pollution, unexpected __proto__ keys, enumerable vs non-enumerable properties) and how these affect feature lookup and security in production.
javascript
function Feature() { this.a = 1; }
Feature.prototype.b = 2;
const f = new Feature();
console.log(f.a, f.b); // 1, 2
f.b = 3; // shadowing prototype property
console.log(f.b); // 3EasyTechnical
0 practiced
Explain JavaScript's property enumeration order (as per ES spec): how integer-like keys, string keys, and symbol keys are ordered when using Object.keys or for..in. As an ML engineer, illustrate how relying on Object.keys() for deterministic feature ordering can lead to bugs, especially when feature names look like integers. Provide an example demonstrating surprising order.
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.
EasyTechnical
0 practiced
Describe and implement (pseudo-code or JS) common Set operations for large sets used in feature engineering: union(A,B), intersection(A,B), and difference(A,B). Discuss time and space complexity and suggest micro-optimizations for very large sets (millions of elements) used in an ML pipeline.
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.