Robert Robert - 7 months ago 23
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?


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?