Robert Robert - 1 year ago 85
Javascript Question

Access parent's parent from javascript object

Something like

var life= {
users : {
guys : function(){ this.SOMETHING.mameAndDestroy(this.girls); },
girls : function(){ this.SOMETHING.kiss(this.boys); },
mameAndDestroy : function(group){ },
kiss : function(group){ }

this.SOMETHING is what I imagine the format is, but it might not be. What will step back up to the parent of an object?

Answer Source

JavaScript does not offer this functionality natively. And I doubt you could even create this type of functionality. For example:

var Bobby = {name: "Bobby"};
var Dad = {name: "Dad", children: [ Bobby ]};
var Mom = {name: "Mom", children: [ Bobby ]};

Who does Bobby belong to?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download