In a previous article, I covered the concept of . In this guide, we used the question mark symbol to denote if a function's argument was optional. optional parameters in TypeScript ? In this guide, let's look at another way of achieving this - with default parameters. Default Parameters Before looking at how these parameters work in TypeScript, let’s recap on how they work in Javascript. Default parameters are already widely supported in Javascript. When we talk about , we are talking about giving arguments values that should be used, if that argument is undefined. For example: default parameters let myFunction = (x, y = "World") => { console.log(x + " " + y); } myFunction("Hello"); In the example above, since is undefined when we call , the default value is used. That avoids the issue where may be if the user doesn't mention it in the function. If we didn't define here, then the function above would console log . y myFunction y undefined y Hello undefined Why use Default Parameters? The example above is a good reason as to why you might want to use default parameters. Here, we don't want the user to see an value. So we will replace with a default, meaning we never show this to user. undefined y Imagine a similar scenario where we show a user's name. In that example, we might not always have the surname. Here, we could use default values to omit it and not show the text to the user: undefined let showName = (firstName, lastName = "") => { return firstName + " " + lastName } As such, default parameters let us improve a user's experience in some cases. They also can be used in other places, such as setting the default position of a shape on an HTML canvas. Default Parameters in TypeScript Fortunately, there isn't much-added complexity in TypeScript when it comes to default parameters. We can add them into our code in the same way - we must also define the types too. let myFunction = (x: string, y: string = "World") => { console.log(x + " " + y); } myFunction("Hello"); Here, we expect both arguments to be strings, but actually, we don't even have to give a type. TypeScript's engine will infer that is a string since its default value is a string: y y let myFunction = (x: string, y = "World") => { console.log(x + " " + y); } myFunction("Hello"); That means that running will still result in a TypeScript error - if we don't explicitly define 's type: myFunction("Hello", 1) even y Argument of type 'number' is not assignable to parameter of type 'string'. Conclusion In conclusion, default parameters can be used the same way as in Javascript. 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, and if we don't, TypeScript will assume the type based on what the default value is. So if the default value was , then TypeScript would assume that that argument was a . 1 number Also published . here