Skip to content

Instantly share code, notes, and snippets.

@robertcoopercode
Created January 9, 2019 00:30
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 robertcoopercode/addd473ed24ca8d5560348fddd49cf3c to your computer and use it in GitHub Desktop.
Save robertcoopercode/addd473ed24ca8d5560348fddd49cf3c to your computer and use it in GitHub Desktop.
// Optional function parameter
function callMom(message?: string) {
if (!message) {
console.log('Hi mom. Love you. Bye.');
} else {
console.log(message);
}
}
// Interface describing an object containing an optional property
interface Person {
name: string;
age: number;
favoriteColor?: string; // This property is optional
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment