Skip to content

Commit 7f9a1fa

Browse files
authored
Update Destructuring-Object.js
1 parent 9927479 commit 7f9a1fa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Destructuring-Object.js

+19
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,22 @@ console.log(mhs.umur); // output: 23
1414
const {nama, umur} = mhs;
1515
console.log(nama); // output: Godam Best
1616
console.log(umur); // output: 23
17+
18+
// Destructuring Nested Object
19+
20+
// Nested Object
21+
const hero = {
22+
name: 'Batman',
23+
realName: 'Bruce Wayne',
24+
address: {
25+
city: 'Gotham'
26+
}
27+
};
28+
29+
// Object destructuring:
30+
const { address: { city } } = hero;
31+
32+
// Result
33+
console.log(city); // output: 'Gotham'
34+
35+

0 commit comments

Comments
 (0)