get object key by value js code example
Example 1: js get object keys
myObject = {
"key": "value"
}
Object.keys(myObject); // get array of keys
Example 2: js find key by value in object
Object.keys(object).find(key => object[key] === value)
Example 3: javascript object get value by key
const person = {
name: 'Bob',
age: 47
}
Object.keys(person).forEach((key) => {
console.log(person[key]); // 'Bob', 47
});