1function getKeyByValue(object, value) {
2 return Object.keys(object).find(key => object[key] === value);
3}
4
5
6const map = {"first" : "1", "second" : "2"};
7console.log(getKeyByValue(map,"2"));
1const person = {
2 name: 'Bob',
3 age: 47
4}
5
6Object.keys(person).forEach((key) => {
7 console.log(person[key]); // 'Bob', 47
8});