From e92bbb1303984daa880ec84b65ba89f286f8e9e6 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Tue, 20 Oct 2020 11:29:31 +0300 Subject: [PATCH] Update article.md --- 1-js/04-object-basics/07-optional-chaining/article.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/1-js/04-object-basics/07-optional-chaining/article.md b/1-js/04-object-basics/07-optional-chaining/article.md index 022e2cd0..f76cf974 100644 --- a/1-js/04-object-basics/07-optional-chaining/article.md +++ b/1-js/04-object-basics/07-optional-chaining/article.md @@ -103,9 +103,7 @@ 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 only `user` to be `null/undefined`. - -On the other hand, if `user` does exist, then it must have `user.address` property, otherwise `user?.address.street` gives an error at the second dot. +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.