Need Assistance?

support@tutorialshub.in

Functions in TypeScript

Optional (?) & Default Parameters

ADVERTISEMENT
TypeScript Free Lesson
5 min read
ADVERTISEMENT

Add ? after a parameter name to make it optional (its type becomes T | undefined). Or assign a default value like limit: number = 10, which makes it optional to callers while guaranteeing a value inside the function.

ADVERTISEMENT
Hi, I'm Tuby! Here to help you