Skip to main content
JavaScript Interview Questions Predict Output P1 Hard

Object keys vs Map keys

Predict the lookup results and the Map size.

Official Reference

Code Snippet

const first = { id: 1 }, second = { id: 1 };
const dictionary = { [first]: "A", [second]: "B" };
const map = new Map([[first, "A"], [second, "B"], [NaN, "C"]]);
console.log(dictionary[first], Object.keys(dictionary).length);
console.log(map.get(first), map.get({ id: 1 }), map.get(NaN), map.size);

Expected Output & Explanation

B 1
A undefined C 3

Both ordinary objects convert to the same property key string here. Map compares objects by identity, but it treats NaN as equal to NaN for key lookup.

Module Context & References

JavaScript · Language output drills Trace closures, receivers, prototypes, coercion and array edge cases
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.