File tree 1 file changed +2
-2
lines changed
1-js/04-object-basics/07-optional-chaining
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -74,12 +74,12 @@ That's why the optional chaining `?.` was added to the language. To solve this p
74
74
75
75
## Optional chaining
76
76
77
- The optional chaining ` ?. ` stops the evaluation if the part before ` ?. ` is ` undefined ` or ` null ` and returns that part .
77
+ The optional chaining ` ?. ` stops the evaluation if the value before ` ?. ` is ` undefined ` or ` null ` and returns ` undefined ` .
78
78
79
79
** Further in this article, for brevity, we'll be saying that something "exists" if it's not ` null ` and not ` undefined ` .**
80
80
81
81
In other words, ` value?.prop ` :
82
- - is the same as ` value.prop ` if ` value ` exists,
82
+ - works as ` value.prop ` , if ` value ` exists,
83
83
- otherwise (when ` value ` is ` undefined/null ` ) it returns ` undefined ` .
84
84
85
85
Here's the safe way to access ` user.address.street ` using ` ?. ` :
You can’t perform that action at this time.
0 commit comments