Javascript while iterate over the object so how to know the key is parents object key or child object key

Shivam Gupta
1 min readJul 10, 2019

--

Creating Object from a different Object

When we iterate over an Object using for (key in obj) loop so we also get parent object key example —

Also, get the parent object keys

we have Object.keys() method which only return the current object key not parent object keys.

way to know which key is a parent and which one is child key

This question is also asked in interviews. If you like my post please give a clap.

--

--

Shivam Gupta
Shivam Gupta

Written by Shivam Gupta

Full Stack Engineer (Web/App) working on different JS Technologies & frameworks— Angular, Node, Typescript, Ionic, Firebase, AWS, ElK...Love to write cool stuff

No responses yet