get object value by key javascript code example
Example 1: javascript object get value by key
const person = {
name: 'Bob',
age: 47
}
Object.keys(person).forEach((key) => {
console.log(person[key]);
});
Example 2: js find key by value in object
Object.keys(object).find(key => object[key] === value)
Example 3: js get all values of object
Object.values(object1)
Example 4: javascript object get value by key
var obj = {
a: "A",
b: "B",
c: "C"
}
console.log(obj.a);
var name = "a";
console.log(obj[name]);