What this snippet does
Combining ?. with ?? gives a clean way to safely read nested data and fall back to a default without if-chains.
Expected output
img.png default.png
Why practise typing this
Typing operators code builds muscle memory for the symbols and indentation JavaScript uses most, which prose-based typing tests never cover. DevType measures your words per minute and accuracy on this snippet and tracks the individual characters you mistype, so later lessons can target them.
More JavaScript practice
- strict equalityOperators · beginner
- logical operatorsOperators · beginner
- nullish coalescingOperators · beginner
- nullish defaultsOperators · beginner
- optional chainingOperators · beginner
- logical assignmentOperators · intermediate