how to loop over an object and get only values in javascript code example
Example 1: loop over keys in object javascript
Object.keys(obj).forEach(function(key) {
console.log(key, obj[key]);
});
Example 2: javascript looping through object
const fruits = {
apple: 28,
orange: 17,
pear: 54,
}
const values = Object.values(fruits)
console.log(values) // [28, 17, 54]