Optional Parameters In TypeScript
[!INFO]-
topic: π¦ TypeScript
links: What is TypeScript
source: TypeScript course by the native web
tags: #permanent-noteΒ #published
Last Modified:
=dateformat(this.file.mtime, "MMM. dd, yyyy - HH:mm")
You can define parameters to be optional with a ?
// Optional parameters
const getFullName = function (firstName: string, lastName?: string): string {
if (!lastName) {
return firstName;
}
return `${firstName} ${lastName}`;
};
const fullName = getFullName('Steve', 'Jobs');