We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1527836 commit 3d71b3aCopy full SHA for 3d71b3a
Destructuring.md
@@ -0,0 +1,29 @@
1
+# Destructuing in JavaScript
2
+
3
+```javascript
4
+// 1
5
+const apiObject = {
6
+ data: {
7
+ user: 'Alex',
8
+ twitterHandle: 'alexpaul'
9
+ },
10
+ status: 200,
11
+}
12
13
+// 2
14
+const { data } = apiObject;
15
16
+// 3
17
+console.log(data);
18
+// { user: 'Alex', twitterHandle: 'alexpaul' }
19
20
+/*
21
+1. An object with various key, value pairs
22
+2. Using destructing to get to only the values we need from an object.
23
+3. Prints out only the { data } key,value pair
24
+*/
25
26
27
+Use destructuring to retrieve status, add to step 2 above as we can use comma delimeter to include more properties for destructuring
28
29
+```
0 commit comments