Update article.md

This commit is contained in:
Ilya Kantor 2020-10-20 11:40:25 +03:00 committed by GitHub
parent 614c5ff214
commit 6393a9fe66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,7 +103,7 @@ alert( user?.address.street ); // undefined
Please note: the `?.` syntax makes optional the value before it, but not any further. Please note: the `?.` syntax makes optional the value before it, but not any further.
E.g. in `user?.address.street.name` the `?.` allows `user` to be `null/undefined`, but it's all it does. Further properties are accessed in a regular way. E.g. in `user?.address.street.name` the `?.` allows `user` to be `null/undefined`, but it's all it does. Further properties are accessed in a regular way. If we want them also be optional, then we'll need to replace more `.` with `?.`.
```warn header="Don't overuse the optional chaining" ```warn header="Don't overuse the optional chaining"
We should use `?.` only where it's ok that something doesn't exist. We should use `?.` only where it's ok that something doesn't exist.