Recursively flatten a nested object, while maintaining key structure
Object to flatten
Optional
Recursively check if key is a parent key or not
Result
const car = {honda: {model: "Civic"}};console.log(flattenObj(car)); //Output {honda.model: "Civic"} Copy
const car = {honda: {model: "Civic"}};console.log(flattenObj(car)); //Output {honda.model: "Civic"}
Recursively flatten a nested object, while maintaining key structure