Suppose I access a certain object that is inside an object, but I don't know what the key of the previous object is, is there any way to get the key of the parent of this object?
Basically I would like to get the relative node of a property of an object
var house = {
bedroom: {
bed: 'I am a bed'
}
}
I got I'm a bed
, I know her key is bed
but I don't know she is in bedroom
is there any way to get bedroom?
just by knowing bed
. It is similar to parentNode, but like in objects.
This is my wish: "bed.parentNode
result bedroom
" but in object;