I have an object:
var Top = {
'A':{},
'b':{
'1':'someText',
'2':'someMoreText'},
'C':{
'3':'evenMoreText',
'4':'thisIsGettingRedundant'},
'D':'thisOneIsDifferent'}
I am looking for a way to access the name of my objects, like Top[b].objectName
would return 'Top'
as a string, I am doing this inside some nested for...in loops, like this:
for(thing in Top){
for(piece in Top[thing]){
console.log('Grabbing ' + Top[thing][piece] + ' from ' + MY_OBJECT_NAME_THAT_SHOULD_BE_TOP);
}
}
I suppose I could add a tag to each object for their name (IE. changing A from {} to 'Top'), but that seems redundant to me.
-Edit:
is there a way to log my second level object names IE. A, B, C? as they SHOULD be logged as data and not code