Skip to content

Commit 1a07fa7

Browse files
authored
Printing Object keys and values
1 parent c5873fe commit 1a07fa7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,25 @@ Object.isFrozen(obj) //true
323323
```
324324
325325
326+
# Printing Object keys and values
327+
328+
329+
```javascript
330+
const obj = {
331+
name: "JSsnippets",
332+
age:29,
333+
};
334+
335+
//Object.entries() method is used to return an array consisting of enumerable property
336+
//[key, value] pairs of the object which are passed as the parameter.
337+
338+
for(let [key,value] of Object.entries(obj)){
339+
console.log(`${key}: ${value}`)
340+
}
341+
342+
//expected output:
343+
// "name: Jssnippets"
344+
// "age: 29"
345+
// order is not guaranteed
346+
347+
```

0 commit comments

Comments
 (0)