Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

object for loop javascript

const object = { a: 1, b: 2, c: 3 };
// method 1
Object.entries(object).forEach(([key, value]) => {
    console.log(key, value)
});

//method 2
for (const key in object) {
  console.log(key, object[key])
}
// same output
// a 1
// b 2
// c 3
 
PREVIOUS NEXT
Tagged: #object #loop #javascript
ADD COMMENT
Topic
Name
3+2 =