I have seen multiple other questions about how to do this, but I am yet to find one that accounts for this scenario.
I have an object (lets call it obj
), which has object properties (lets call them objProp
). I need to find the key of an objProp
so I can delete it from obj
. I run into an issue because I cannot use indexOf
or anything like this because my values are objects themselves.
//obj declaration etc
delete obj[getKeyByValue(obj, objProp)];
function getKeyByValue(object, value) {
return Object.keys(object).find(key => object[key] === value);
};
the above will not work because objProp
is another object, is there another way this can be done?