Read here. Code on desktop. The coding workspace opens on screens 1024px and wider.
JavaScript interview question
Intersection By
medium20 min
Find unique values shared by every input array, comparing values through a derived key.
Requirements
Implement intersectionBy(arrays, iteratee), where arrays is an array of dense arrays and iteratee is a callback or a direct property key. This explicit array-of-arrays signature supports any number of inputs.
Return original values from the first array whose computed keys occur in every array. Keep first-array order, and include only the earliest first-array item for each shared key.
Compare keys using SameValueZero, as Set does: NaN matches NaN, 0 matches -0, and objects/symbols compare by identity. Do not stringify keys or deeply compare them.
A callback receives only the value. For nonempty inputs, evaluate it once per item, caching the derived keys. Property-key iteratees read the direct property, including symbols.
Zero input arrays or any empty input array return a fresh empty array without calling the iteratee. A single input array returns its values deduplicated by key. Do not mutate input, clone returned values, or hide callback errors.