looping through an object (tree)
- by Val
Is there a way (in jquery or javascript) to loop through each object and it's children and gandchildren and so on.
if so... can i also read their name?
example
foo :{
bar:'',
child:{
grand:{
greatgrand: {
//and so on
}
}
}
}
so the loop should do something like this...
loop start
if(nameof == 'child'){
//do something
}
if(nameof == 'bar'){
//do something
}
if(nameof =='grand'){
//do something
}
loop end
I know this is stupid code but i tried to make it understandable :)
btw this is for a jquery UI, as i am clueless how to go on about this.
thanks