Tim Mouskhelichvili • October 24, 2022 • 3 minutes to read
When preparing for a coding interview, you may have encountered the queue data structure and wanted to implement it in a TypeScript project. Luckily, this is easy to do. The queue data structure is a list of elements that [...]
Tim Mouskhelichvili • October 17, 2022 • 2 minutes to read
When using object-oriented programming concepts in TypeScript, often a developer needs to make a class implement an interface. Luckily, this is easy to do. To make a class implement an interface in TypeScript, you need to use the special [...]
Tim Mouskhelichvili • October 12, 2022 • 3 minutes to read
To create a read-only property in TypeScript, you need to use the readonly keyword. Here is an example of a read-only property inside an interface: interface IPerson { readonly name: string; role: string; } This article explains everything about [...]
Tim Mouskhelichvili • October 11, 2022 • 2 minutes to read
TypeScript offers multiple loop types to iterate through a piece of code. Some are well known and used a lot, like the for loop. Others are less used, like the while loop. The while loop runs some code while [...]
Tim Mouskhelichvili • October 10, 2022 • 3 minutes to read
Enums are useful when you have a fixed set of constants. Sometimes, a developer needs to transform a TypeScript enum into an array. Luckily, this is easy to do. To transform an enum into an array in TypeScript, you [...]
Tim Mouskhelichvili • October 5, 2022 • 2 minutes to read
In TypeScript, arrays are one of the most useful data structures. They can store a collection of values of any data type. Sometimes, a developer might need to get the last element of an array. Luckily, it is easy [...]
Tim Mouskhelichvili • October 4, 2022 • 2 minutes to read
When developing a web application or TypeScript library, a developer may need to initialize an empty typed object. Luckily, it is easy to achieve. To initialize an empty typed object in TypeScript, you can: Use type assertion Create a [...]
Tim Mouskhelichvili • October 3, 2022 • 2 minutes to read
When declaring an empty array in TypeScript, the compiler cannot infer its type by default. That's why you need to specify the array's type explicitly. Luckily, it is easy to do. Here is one way to declare an empty [...]
Tim Mouskhelichvili • September 28, 2022 • 3 minutes to read
TypeScript adds strong typings to your JavaScript. Everything has its type in TypeScript. However, the compiler is sometimes incorrect and infers the wrong type. Luckily, TypeScript offers a special keyword to cast object types. The as keyword converts an [...]
Tim Mouskhelichvili • September 27, 2022 • 2 minutes to read
Sometimes, a TypeScript developer may need to find the class name of an object. Luckily, it is easy to do. To find the class name of an object at runtime in TypeScript, you can: Use the constructor property of [...]