get object key value js code example
Example 1: foreach object js
const object1 = {
a: 'somestring',
b: 42
};
for (let [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
Example 2: get keys of dictionary js
let dict = { a:1 , b:2 , c:3 }
console.log( Object.keys(dict) )
Example 3: js get object keys
myObject = {
"key": "value"
}
Object.keys(myObject);
Example 4: javascript object get value by key
const person = {
name: 'Bob',
age: 47
}
Object.keys(person).forEach((key) => {
console.log(person[key]);
});
Example 5: object.keys
const object1 = {
a: 'somestring',
b: 42,
c: false
};
console.log(Object.keys(object1));