0
let x = {
    name:"vin1",
    oi:this,
    ob:{
        name:"vin2",
        ob1:{
            name:'vin3',
            ob2:{
                name:"vin4",
                func:function(){
                    console.log(name);  //  I want to access the name "vin1" here.
                }
            }
        }
    }
};

I found this answer which says it's not natively supported in JS. Any way to access the outer object property from the inner object?

Vinay
  • 21
  • 3
  • `x.name`, as shown in the third answer. If you don't have a reference to the top level object already, then there isn't really anything you can do – CertainPerformance Feb 25 '20 at 08:58
  • @CertainPerformance How can I get the reference to the top level object in the inner object? – Vinay Feb 25 '20 at 09:10
  • *If you don't have a reference to the top level object already, then there isn't really anything you can do* – CertainPerformance Feb 25 '20 at 09:11
  • Wow! I was so fixated on getting the value by going up the ladder that I forgot I can access 'x' directly in the console.log().. Thanks @CertainPerformance – Vinay Feb 25 '20 at 09:13

0 Answers0