Update article.md

This commit is contained in:
Ilya Kantor 2020-10-20 11:34:54 +03:00 committed by GitHub
parent e92bbb1303
commit 1197b01da5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,10 +101,6 @@ alert( user?.address ); // undefined
alert( user?.address.street ); // undefined
```
Please note: the `?.` syntax makes optional the value before it, but not any further.
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.
```warn header="Don't overuse the optional chaining"
We should use `?.` only where it's ok that something doesn't exist.