Created
December 17, 2019 18:26
-
-
Save carlrip/728aa360623730615d64afdcb2b9084f to your computer and use it in GitHub Desktop.
optional chaining
This file contains 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
function getPersonPostcode(id: number) { | |
const person: Person = getPerson(id); | |
return person.address?.zipcode; // returns `undefined` if `address` is `undefined` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment