Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63d7d7d

Browse files
authored
Aliases with JavaScript Destructuring
1 parent444412a commit63d7d7d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,24 @@ const countMyFruits = myFruits.reduce((countFruits,fruit) => {
251251
console.log(fruitsCounter)
252252
// { Apple:3, Banana:1, Mango:2, Orange:1 }
253253
```
254+
255+
256+
# Aliases with JavaScript Destructuring
257+
258+
259+
```javascript
260+
261+
//There are cases where you want the destructured variable to have a different name than the property name
262+
263+
const obj = {
264+
name: "JSsnippets"
265+
};
266+
267+
268+
// Grabs obj.name as { pageName }
269+
const { name: pageName } = obj;
270+
271+
//log our alias
272+
console.log(pageName) // JSsnippets
273+
```
274+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp