Flatten Object in JavaScript | Interview Question Explained

Опубликовано: 12 Май 2026
на канале: Js For Interview
4
1

🔥 JavaScript Interview Question | Flatten Object

In this video, we solve a very popular JavaScript interview question 👇

👉 Flatten a deeply nested object (including arrays) into a single-level object

We use recursion to break down nested structures and convert them into a flat key-value format.

💡 Topics covered:

Recursion in JavaScript
Handling nested objects & arrays
Building dynamic keys
Real interview approach

📌 Example:
Input: { A: { B: { C: ["value0", "value1"] } } }
Output: { "A.B.C.0": "value0", "A.B.C.1": "value1" }

This question is commonly asked in frontend interviews at companies like Amazon, Flipkart, etc.

👍 If this helped you, don’t forget to LIKE 👍, SHARE 🔁, and SUBSCRIBE 🔔 for more coding interview questions

#javascript #codinginterview #frontend #webdevelopment #recursion #learnjavascript