Update article.md

This commit is contained in:
Ilya Kantor 2020-10-20 08:24:11 +03:00 committed by GitHub
parent d6e88647b4
commit 030decc910
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,9 +9,11 @@ The optional chaining `?.` is a safe way to access nested object properties, eve
If you've just started to read the tutorial and learn JavaScript, maybe the problem hasn't touched you yet, but it's quite common.
As an example, consider objects for user data. Most of our users have addresses in `user.address` property, with the street `user.address.street`, but some did not provide them.
As an example, consider objects that hold user data.
In such case, when we attempt to get `user.address.street`, we may get an error:
Most of our users have addresses in `user.address` property, with the street `user.address.street`, but some did not provide them.
In such case, when we attempt to get `user.address.street` of a user, and there's no address, then we get an error:
```js run
let user = {}; // a user without "address" property