Skip to content

Commit 3c5cc8e

Browse files
authored
Merge pull request #2929 from Rnbsov/patch-18
Maybe it should be marked as code
2 parents ed664f8 + f613e03 commit 3c5cc8e

File tree

1 file changed

+1
-1
lines changed
  • 1-js/04-object-basics/07-optional-chaining

1 file changed

+1
-1
lines changed

1-js/04-object-basics/07-optional-chaining/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ userGuest.admin?.(); // nothing happens (no such method)
182182
183183
Here, in both lines we first use the dot (`userAdmin.admin`) to get `admin` property, because we assume that the `user` object exists, so it's safe read from it.
184184
185-
Then `?.()` checks the left part: if the admin function exists, then it runs (that's so for `userAdmin`). Otherwise (for `userGuest`) the evaluation stops without errors.
185+
Then `?.()` checks the left part: if the `admin` function exists, then it runs (that's so for `userAdmin`). Otherwise (for `userGuest`) the evaluation stops without errors.
186186
187187
The `?.[]` syntax also works, if we'd like to use brackets `[]` to access properties instead of dot `.`. Similar to previous cases, it allows to safely read a property from an object that may not exist.
188188

0 commit comments

Comments
 (0)