Converting Nested Objects to Flat Objects in JavaScript: A Quick Guide
SMRTR summary
Flattening a nested JavaScript object is a classic interview question that tests your understanding of recursion, object traversal, and a sneaky JavaScript quirk: arrays are objects too. A recursive solution using key prefixes works cleanly, but naive implementations accidentally destructure arrays into indexed keys. Adding an Array.isArray check fixes the edge case and produces correct output.
SMRTR provides this summary for quick context. The original article belongs to Hacker Noon.
Read the original article