Skip to content

Commit 8eb6f97

Browse files
committed
minor fixes
1 parent 99b2a09 commit 8eb6f97

File tree

1 file changed

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

1 file changed

+3
-5
lines changed

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,16 @@ Then `?.()` checks the left part: if the admin function exists, then it runs (th
173173
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.
174174
175175
```js run
176+
let key = "firstName";
177+
176178
let user1 = {
177179
firstName: "John"
178180
};
179181

180-
let user2 = null; // Imagine, we couldn't authorize the user
181-
182-
let key = "firstName";
182+
let user2 = null;
183183

184184
alert( user1?.[key] ); // John
185185
alert( user2?.[key] ); // undefined
186-
187-
alert( user1?.[key]?.something?.not?.existing); // undefined
188186
```
189187
190188
Also we can use `?.` with `delete`:

0 commit comments

Comments
 (0)