Tim Mouskhelichvili • December 13, 2022 • 3 minutes to read
Nowadays, an arrow function is the default and easiest way to define a function in TypeScript and JavaScript. But how does it work exactly? Here is an example of an arrow function in TypeScript: const sum = (x: number [...]
Tim Mouskhelichvili • December 12, 2022 • 2 minutes to read
Sometimes, a TypeScript developer wants to make an arrow function accept different types. That's where generic functions come into play. To make an arrow function generic, you need to add a generic parameter to it like this: const getX [...]
Tim Mouskhelichvili • August 2, 2022 • 3 minutes to read
When working on a TypeScript repository, developers want to keep the files short, making it easier to navigate the code and debug. This leads to the TypeScript repository having many different files. For those TypeScript files to work together [...]
Tim Mouskhelichvili • July 26, 2022 • 2 minutes to read
Named parameters exist in multiple languages such as C# or PHP, and developers from those languages may expect that TypeScript also provides this feature. Unfortunately, this language does not provide true named parameters. However, it is still possible to [...]
Tim Mouskhelichvili • July 20, 2022 • 3 minutes to read
Sometimes developers need to define a default parameter for a TypeScript function. Luckily, TypeScript, just like its counterpart JavaScript, offers a simple way to define default parameters. In TypeScript, you can define a default parameter like so: const getUser [...]
Tim Mouskhelichvili • July 6, 2022 • 3 minutes to read
As you may know, TypeScript is a strongly typed language. By default, when you declare a function with parameters, you need to pass values for each parameter when you call it. Sometimes, however, developers may want to make a [...]
Tim Mouskhelichvili • April 7, 2022 • 7 minutes to read
Functions are part of the basic fundamental concepts of programming that every developer needs to understand. A function is a reusable piece of code that performs a specific task. Functions are the fundamental building blocks of any web application [...]