const obj = {
name: 'Jean-Luc Picard',
rank: 'Captain'
};
// Prints "name Jean-Luc Picard" followed by "rank Captain"
Object.keys(obj).forEach(key => {
console.log(key, obj[key]);
});
// Easy access to key and value :)
let myObj = {name: 'Jojo', family: 'Lopez'}
for (const [key, value] of Object.entries(myObj)) {
console.log('key is:', key);
console.log('value is:', value);
}
// key is: name
// value is: Jojo
// key is: family
// value is: Lopez
const obj = {
a: 1,
b: 2,
c: 3
};
for (let key in obj) {
console.log(key + " = " + obj[key]);
}
// Ausgabe:
// "a = 1"
// "b = 2"
// "c = 3"
Object.keys(object).map(function(objectKey, index) {
var value = object[objectKey];
console.log(value);
});