Skip to content

Commit e92bbb1

Browse files
authored
Update article.md
1 parent 9ad8f66 commit e92bbb1

File tree

1 file changed

+1
-3
lines changed
  • 1-js/04-object-basics/07-optional-chaining

1 file changed

+1
-3
lines changed

1-js/04-object-basics/07-optional-chaining/article.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ alert( user?.address.street ); // undefined
103103
104104
Please note: the `?.` syntax makes optional the value before it, but not any further.
105105
106-
In the example above, `user?.address.street` allows only `user` to be `null/undefined`.
107-
108-
On the other hand, if `user` does exist, then it must have `user.address` property, otherwise `user?.address.street` gives an error at the second dot.
106+
In the example above, `user?.address.street` allows `user` to be `null/undefined`, but `user` does exist, then further access uses a plain dot `.`, so it must have `user.address` property, otherwise `user?.address.street` gives an error at the second dot.
109107
110108
```warn header="Don't overuse the optional chaining"
111109
We should use `?.` only where it's ok that something doesn't exist.

0 commit comments

Comments
 (0)