Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Answers


Since TypeScript is a strongly typed language so it is type checked at compile time, reason In TypeScript, every parameter is assumed to be required by the function.

Check following example which throws error:

optional and Default valued parameters in TypeScript are useful features which can help us remove code redundancy when we use method overloads.

Default valued parameters in TypeScript

Default valued parameters in Typescript feature in allows to use default value when value is not supplied.

Check following example (works perfectly with default value):

var mathCal = (a: number, b: number = 2): number => (a + b);
var result = mathCal(1); 

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.