How to Use Default Parameters in TypeScriptby@smpnjn
1,437 reads

How to Use Default Parameters in TypeScript

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Default parameters are already widely supported in Javascript. They are used to give arguments values that should be used, if that argument is undefined. In the example above, since `y` is undefined when we call `myFunction, the default value is used. This avoids the issue where `y' may be `undefined` if the user doesn't mention it in the function. The only additional thing to consider is that we don't have to always define a type on a parameter that has a default value.
featured image - How to Use Default Parameters in TypeScript
Johnny Simpson HackerNoon profile picture

@smpnjn

Johnny Simpson

Product, Engineering, Web


Receive Stories from @smpnjn

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!