Sometimes, we need to replace a substring with a new string or any particular character while working with TypeScript. The simple way to replace the substring or part of the string is to use the replace() method. Here, we will create a custom algorithm to replace the string for the interview purpose of the beginners. However, we will also see the replace() method at last in this tutorial. Create the Custom Algorithm to Replace the Substring We will use the for loop to iterate through the main string in this part. We will use the substr() method of the string ... Read More
Type assertion is a mechanism in TypeScript that informs the compiler of the variable type. We can override the type using a type assertion if TypeScript finds that the assignment is wrong. We must be certain that we are correct since the assignment is always legitimate when we employ a type assertion. If not, our program might not operate properly. Declaratively informing the compiler that we intend to regard the item as a distinct type is known as type assertion. Using this, we can regard any as a number or a number as a string. When moving code from JavaScript ... Read More
In TypeScript, the typeof is one of the most helpful operators and keywords to check the types of variables or identifiers. However, TypeScript is a type-strict language. So, we need to define the type of the variable or object while defining the identifier itself. Still, sometimes we need to check the type of the variable. For example, we are taking the data from the user via forms and handling it via TypeScript. Then we have to validate the data and perform some database operations. Also, the identifier can have multiple types in TypeScript. So, using the typeof operator, we can ... Read More
We will learn to specify the option properties in TypeScript. The true meaning of the optional property is that properties can be undefined or null, and we can initialize them whenever required. In real-time development, the importance of optional properties is very much. For example, we are fetching the data from the API and performing some operations on the data. If you try to use the data without getting it due to the database server being down or if there is any other problem, it will raise an error. In such case, we can make the data property optional and ... Read More
The string contains various characters, and the substring is the part of the string. We can get the substring from the string two ways. The first is using the starting and ending position of the substring, and the second is using the starting position and length of the substring. We will learn both ways to get the substring from the string in TypeScript in this tutorial. Get The Substring Using The Start Position and End Position In TypeScript, indexing of string starts from zero. So, if we have a zero-based starting and ending position of the substring, we can get ... Read More
The natural logarithm is the logarithm of any numeric value to the base e. Here e is Euler's constant, and the value of Euler’s constant is approximately 2.718. In TypeScript, we can use the built-in library methods to find the natural logarithm of any numeric value greater than or equal to zero. Using the Math.log() Method Math is a library of TypeScript which contains all the methods to perform mathematical operations. Inside the Math object, all methods are static. So, we can directly access all methods by taking Math (object name) as a reference. The math method also contains the ... Read More
In TypeScript, the array contains the data or different values and can also contain an object. The object contains the properties and methods in TypeScript. We can access the object properties and invoke the object method by taking the object as a reference. In this tutorial, we will learn to create an array of multiple objects in TypeScript. We will also learn to perform some operations, such as sorting on the array of objects. Syntax Here, we have given the syntax to follow to create the array of objects. let obj_array: Array = [{object properties}] In the above syntax, ... Read More
Before getting into “enum, ” it is essential to know about the popular keyword “const” in typescript. When we declare a variable "const", we cannot change the value assigned to it. So, enums are nothing but a collection of these const data types. We can create enums with the help of the "enum" keyword. Enum is an abbreviation for Enumerations, and each constant variable declared under the enum is called a member of that enum. In this article, we will learn about enums in typescript, their features, and the major types of enums. Features of enum in TypeScript Enums ... Read More
We will learn to find the last index of the element in the array in TypeScript. In development, an array of the data can contain duplicate data, and we may need to keep the last occurrence of the element. For example, we have fetched all users’ login history from the database. Now, we want to find when particular users were logged in for the last time. In such scenarios, we can use the below methods to find the last occurrence of the element in the array. Search from the last in the array To find the last occurrence of the ... Read More
Overview By utilizing Bash scripts, we can have access to a powerful programming language. Writing such scripts is an efficient way to run several commands one after the other. Even if one command fails, the others will still be executed. We’ll learn how we can add some safeguards so that these errors don't happen. The example code has been tested in Bash. They should also work for other POSIX-compatible shell environments. The Problem Let’s first take a look at how Bash handles error messages by default. Let's say we have a simple shell script called "hello.sh" which prints out the ... Read More
 
 Data Structure
 Data Structure Networking
 Networking RDBMS
 RDBMS Operating System
 Operating System Java
 Java MS Excel
 MS Excel iOS
 iOS HTML
 HTML CSS
 CSS Android
 Android Python
 Python C Programming
 C Programming C++
 C++ C#
 C# MongoDB
 MongoDB MySQL
 MySQL Javascript
 Javascript PHP
 PHP 
		