Skip to content

Commit 9e210b7

Browse files
committed
minor fixes
1 parent bf6d3c9 commit 9e210b7

File tree

1 file changed

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

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ E.g. in `user?.address.street.name` the `?.` allows `user` to safely be `null/un
108108
```warn header="Don't overuse the optional chaining"
109109
We should use `?.` only where it's ok that something doesn't exist.
110110

111-
For example, if according to our coding logic `user` object must exist, but `address` is optional, then we should write `user.address?.street`, but not `user?.address?.street`.
111+
For example, if according to our code logic `user` object must exist, but `address` is optional, then we should write `user.address?.street`, but not `user?.address?.street`.
112112

113113
So, if `user` happens to be undefined due to a mistake, we'll see a programming error about it and fix it. Otherwise, coding errors can be silenced where not appropriate, and become more difficult to debug.
114114
```
@@ -179,7 +179,7 @@ let user1 = {
179179
firstName: "John"
180180
};
181181

182-
let user2 = null;
182+
let user2 = null;
183183

184184
alert( user1?.[key] ); // John
185185
alert( user2?.[key] ); // undefined

0 commit comments

Comments
 (0)