Update article.md

This commit is contained in:
LeviDing 2020-11-15 20:09:54 +08:00 committed by GitHub
parent 7a67741a9b
commit 75e10e203e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,7 @@ let user = {}; // a user without "address" property
alert(user.address.street); // Error!
```
That's the expected result. JavaScript works like this. As `user.address` is `undefined`, an attempt to get `user.address.street` fails with an error.
That's the expected result. JavaScript works like this. As `user.address` is `undefined`, an attempt to get `user.address.street` fails with an error.
In many practical cases we'd prefer to get `undefined` instead of an error here (meaning "no street").