Skip to content

Commit 1d3ec50

Browse files
committed
add slug
1 parent c7d1fbf commit 1d3ec50

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ console.log(list);
1313
// 2nd [ 7, 8, 4, 3, 6, 9, 5, 2, 1 ]
1414
```
1515

16+
### 🔎 [Slug](https://github.com/ekaone/JavaScript-Goodies/blob/master/objectEntriesSlug.js)
17+
```js
18+
const posts = {
19+
"mountain-view": {
20+
name: "Everest",
21+
height: 8848
22+
},
23+
"building-world": {
24+
name: "Burj Khalifa",
25+
height: 828
26+
}
27+
};
28+
29+
const slugs = Object.entries(posts).map(([slug, { name, height }]) => {
30+
return slug;
31+
});
32+
33+
console.log(slugs); // [ 'mountain-view', 'building-world' ]
34+
```
35+
1636
### 🔎 [IIFE](https://github.com/ekaone/JavaScript-Goodies/blob/master/iife.js)
1737
```js
1838
(function() {

objectEntriesSlug.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ const posts = {
1212
const slugs = Object.entries(posts).map(([slug, { name, height }]) => {
1313
return slug;
1414
});
15+
16+
console.log(slugs); // [ 'mountain-view', 'building-world' ]

0 commit comments

Comments
 (0)