Sometimes, a TypeScript developer may want to add a global variable to the code base. Luckily, this is easy to do.
To add a new global variable to TypeScript, you can:
Augment the global object (when running in a [...]
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 [...]
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 [...]
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 [...]
When creating a React web application or library, often a developer needs to import JSON data. A typical example is having a JSON file with country names used by the React web application. Luckily, it is easy to achieve [...]
The react-router package is a fantastic library that enables React applications to have different routes that users can view. It has various features; however, one of its most significant ones is its ability to manipulate the browser history inside [...]
Images are often the most significant elements (size-wise) to load on a website. That's why it is best only to load the images that the user sees, and when the user scrolls, progressively load the others. This brings the [...]
Whether you are creating a single-page application or an e-commerce store, there is often a situation when you need to get the URL of the current page. Luckily, this is easy to accomplish in React.
To get the current [...]
When working on a React web application, buttons are one of the most common elements a developer will use. Sometimes, a developer may want to enable a button conditionally. This situation brings the question of how to disable a [...]
React provides a simple way to build web applications. Often, those applications require adding links to other Internet resources. This brings the question of how to open a link in a new tab. Luckily it is easy to accomplish [...]