Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript loop through object key, value

// `for...of` loop
for (const [key, value] of Object.entries(animals)) {
    console.log(`${key}: ${value}`);
}

// `forEach()` method

Object.entries(animals).forEach(([key, value]) => {
    console.log(`${key}: ${value}`)
});
Source by flexiple.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #loop #object
ADD COMMENT
Topic
Name
5+1 =