Advertisement
728x90
The Object.entries() method is used to return an array of a given object's own enumerable string-keyed property [key, value] pairs, in the same order as that provided by a for...in loop. Let's see the functionality of object.entries() method in an example,
javascript
1const object = {
2 a: "Good morning",
3 b: 100,
4 };
5
6for (let [key, value] of Object.entries(object)) {
7 console.log(`${key}: ${value}`); // a: 'Good morning'
8 // b: 100
9}Note: The order is not guaranteed as object defined.
Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 30
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
200of476