Created
November 27, 2020 09:42
-
-
Save nivrith/346d8a1cd096eb6e2c3b2a8b55bbe5c2 to your computer and use it in GitHub Desktop.
Optional Chaining
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let petName; | |
| if(person && person.pet && person.pet.name) { | |
| petName = person.pet.name; | |
| } | |
| //Can be condensed to | |
| let petName = person?.pet?.name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment