Skip to content
Advertisement

How to flatten an object with nested objects in javascript

I have some attributes from a nested object that is inside the parent object but I would like to merge nested object with the parent object to be flatten.

Original object:

JavaScript

expected flatten object:

JavaScript

Advertisement

Answer

You can recursively build object any number of nested objects. So, this function is not your case dependent:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement