Read here. Code on desktop. The coding workspace opens on screens 1024px and wider.
JavaScript interview question
Union By
medium20 min
Combine arrays into one ordered list, keeping the first value for every distinct computed key.
Requirements
Implement unionBy(arrays, iteratee), using an explicit array-of-arrays signature. Inputs are dense arrays. iteratee is a callback or a direct property key, including symbols.
Visit arrays in input order and items in their own order. Return the earliest original value for every unique computed key, preserving reference identity.
Compare computed keys with SameValueZero: NaN equals NaN, 0 equals -0, and objects/symbols use identity. Do not stringify keys or deeply compare them.
A callback receives only the value and runs once per item, including items whose keys were already seen. Direct property lookup is not a deep path.
Zero arrays or only empty arrays return a fresh empty array without callback invocations. Do not mutate inputs or hide iteratee errors.