const key = Object.keys(obj).find(key => obj[key] === value);
function getKeyByValue(object, value) {
return Object.keys(object).find(key => object[key] === value);
}
const map = {"first" : "1", "second" : "2"};
console.log(getKeyByValue(map,"2"));
Run code snippetHide results
const findingKey = (obj , value) => (Object.keys(obj).find(key => value === obj[key]))
console.log(findingKey({id:"123",name:"Alice"},"Alice");