—
const obj = { prop: {} };
const { prop } = obj;
const nameOfProp = Object.entries(obj)
.find(x => x[1] === prop)[0];
If I want to find the key that was used for
prop
in
obj
, I would use this method,
nameOfProp
would then contain
"prop"
Message permanent page