Question 1
Topic: Variables, types, and collections
Skill tested: Selects Map and Set structures to preserve key identity and enforce unique values.
A JavaScript service processes product records from an upstream system. Each record has an object-valued `product` reference and a list of related category names. The service must look up metadata by the exact product object reference and produce a de-duplicated list of category names while preserving their first-seen order. Product references must not be converted to strings, and the implementation should use standard JavaScript collections. Which design satisfies both requirements?
A `Map` accepts object keys and compares them by object identity, so it can distinguish the exact product references without string conversion. A `Set` stores unique values and iterates in insertion order, preserving the first-seen order of category names. A plain object with stringified keys can collapse distinct references and sorting changes encounter order. A `WeakMap` is not iterable, so it does not suit general collection processing, while a `WeakSet` accepts only objects and cannot store category strings.