Skip to content

Commit c0a0113

Browse files
authored
Add bracket notation for object property access example (#433)
1 parent b2f3129 commit c0a0113

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎Sprint-2/debug/address.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@ const address = {
1414

1515
// You can't get values from objects using indexes, you need to reference a key in the object
1616

17+
// To reference object key you can have two notations:
18+
19+
// object.key
20+
// object['key']
21+
22+
// Bracket notation is useful when your property name has spaces or it is a variable.
23+
1724
console.log(`My house number is ${address.houseNumber}`);
25+
26+
// or
27+
28+
console.log(`My house number is ${address['houseNumber']}`);

0 commit comments

Comments
 (0)