Tuesday 6 June 2017

Create path from javascript object property

Let's say I've got the following javascript object

var obj = {
            a:{
                b:"value",
                c:{
                    d:"value2"
                }
            }
        }

What function would, when input with the "d" object (for example, function getPath(d), output the "a.c.d" string? I've tried various things including object-path, but it doesn't seem to be designed for that



via user2950509

No comments:

Post a Comment