javascript print key of object code example
Example 1: print object javascript
str = JSON.stringify(obj);
str = JSON.stringify(obj, null, 4);
console.log(str);
alert(str);
Example 2: for key value in object javascript
for (const [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
Example 3: object keys javascript
const object1 = {
a: 'somestring',
b: 42,
c: false
};
console.log(Object.keys(object1));
Example 4: object.keys javascript
const object1 = {
a: 'somestring',
b: 42,
c: false
};
console.log(Object.keys(object1));