Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  189] [ 7]  / answers: 1 / hits: 17942  / 11 Years ago, sat, february 23, 2013, 12:00:00

I have following code:



var objectParent:{
child1:{
test1:function(){},
test2:function(){}
},

child2:{
demo1:function(){},
demo2:function(){},
parent:this // gives child2
grandparent: .... // need to reference objectParent here

}

}


We can reference object by using this keyword, But what for grand object or i mean parent of parent object?



Now, i am using grandparent:objectParent to reference parent object



Is there other way like this selector to reference parentObject?



Are these my coding is bad,good or better?


More From » javascript

 Answers
10

If all your objects have a parent property that refers to their parent, then can get the grandparent with object.parent.parent.


[#80052] Thursday, February 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
benitoh

Total Points: 150
Total Questions: 113
Total Answers: 104

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
benitoh questions
Sun, Mar 21, 21, 00:00, 3 Years ago
Mon, May 13, 19, 00:00, 5 Years ago
;