Getting all paths of an JavaScript object

I recently came across a problem where I needed to iterate through a JavaScript object and apply an operation to another object with the same structure. The best way I've found to iterate through objects is by keeping track of references to child objects. This means any operations you want to perform must be contained with in that object.

Lodash has an useful _.get method for reaching many levels deep with in an object. I realized if I could construct this path programmatically in one of the objects, I'd be able to iterate through it and get the reference I needed in the other.

Bret Lowrey

Code is like a war - the best code is one never written.

Florida, USA