Skip to content

Instantly share code, notes, and snippets.

@carlrip
Created December 17, 2019 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlrip/728aa360623730615d64afdcb2b9084f to your computer and use it in GitHub Desktop.
Save carlrip/728aa360623730615d64afdcb2b9084f to your computer and use it in GitHub Desktop.
optional chaining
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