How to get the path from javascript object from key and value

I have a javascript object width depth.

I need to know the exact path from this key within the object ex: “obj1.obj2.data1”

I already know the key is data1, the value is 123.

My javascript object look like this

    obj1: {
        obj2: {
            data1: 213,
            data2: "1231",
            obj3: {
                data: "milf"
    obj4: {
        description: "toto"

How could I achieve that ?

here is a jsfiddle :
I am trying to implement getPath.

77 thoughts on “How to get the path from javascript object from key and value”

  1. Pingback: keto salmon
  2. I don’t know whether it’s just me or if perhaps everyone else encountering issues with your
    website. It appears as if some of the text on your
    content are running off the screen. Can someone else please provide feedback and let me know if this is happening to them too?
    This may be a problem with my internet browser because I’ve
    had this happen before. Thanks

  3. Its like you read my mind! You appear to know so much about this,
    like you wrote the book in it or something.
    I think that you could do with a few pics to drive the message home a bit,
    but other than that, this is magnificent blog. A great read.
    I’ll certainly be back.

  4. Thanks for some other informative site. The place else
    may I get that kind of info written in such a perfect means?
    I’ve a undertaking that I’m simply now operating on, and I have
    been on the glance out for such information.

  5. Oh my goodness! Impressive article dude! Many
    thanks, However I am having problems with your RSS.
    I don’t understand why I cannot join it. Is there anybody getting similar RSS problems?
    Anyone that knows the answer will you kindly respond? Thanx!!


Leave a Comment