Problem, as an interviewer would state it:
"Implement objectDiff(a, b) — returning a description of how object b differs from object a: which paths were added, which were removed, and which changed (with the old and new value), recursing into nested objects."
Examples:
objectDiff({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 }, d: 4 });
// added: { d: 4 }, removed: {}, changed: { "b.c": { from: 2, to: 3 } }
Clarifying questions expected:
- What output shape is wanted — flat dot-paths, or a nested structure mirroring the input?
- How should arrays be compared, and how should
NaN,+0and-0be treated? - Must a key that exists with the value
undefinedbe distinguished from a missing key?
Code / implementation expected: Yes — real, direct proof of each category, of nested paths, and of the equality edge cases.