Skip to content

Commit 1197b01

Browse files
authored
Update article.md
1 parent e92bbb1 commit 1197b01

File tree

1 file changed

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

1 file changed

+0
-4
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ alert( user?.address ); // undefined
101101
alert( user?.address.street ); // undefined
102102
```
103103
104-
Please note: the `?.` syntax makes optional the value before it, but not any further.
105-
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.
107-
108104
```warn header="Don't overuse the optional chaining"
109105
We should use `?.` only where it's ok that something doesn't exist.
110106

0 commit comments

Comments
 (0)