TypeScript Articles

Page 8 of 8

How to push an element at the beginning of an array in TypeScript?

Shubham Vora
Shubham Vora
Updated on 19-Dec-2022 13K+ Views

In this tutorial, we will learn to push the elements at the start of the array in TypeScript. There are different ways to push single or multiple elements at the start of the array in TypeScript. Here, we will learn three different methods to push array elements at the array's starting index. Using the Array.unshift() Method The Array.unshift() method of TypeScript allows us to add the element into the array at the beginning. Also, we can add multiple elements at the start of the array using the Array.unshift() method. Syntax Users can follow the syntax below to use the array.unshift() ...

Read More

How to override multiple if-else conditions using a switch statement in TypeScript?

Shubham Vora
Shubham Vora
Updated on 19-Dec-2022 2K+ Views

In this tutorial, we will learn to override the multiple if-else conditions using the switch case statement in TypeScript. The single if-else statement is used to execute the condition statement. If the condition becomes true, the statement of if block executes otherwise control fallbacks to the else block and executes its statement. In some cases, developers must execute the code blocks on different conditions. For that, they require to write multiple if-else statements of ladder of if-else statements. Here, we will convert that ladder of if-else statements to switch case statements. Converting If-else conditions to Switch Statement in TypeScript Here, ...

Read More

How to find the total number of elements in an array in TypeScript?

Shubham Vora
Shubham Vora
Updated on 16-Dec-2022 22K+ Views

In this tutorial, we will learn to find the total number of elements in the array. In TypeScript, the array is the data structure containing various elements such as integers, strings, objects, etc. While working with the APIs and performing operations with the data often requires counting the total number of elements in the array. Also, sometimes it requires counting the number of elements in the array based on certain conditions. Here, we have focused on various methods to count a total number of elements in the array. Using the length property of the array in TypeScript The array prototype ...

Read More

How to filter values from an array in TypeScript?

Shubham Vora
Shubham Vora
Updated on 16-Dec-2022 11K+ Views

In this tutorial, users will learn to filter the values from the array in TypeScript. The filter is an important operation to manipulate the data we get from the database. For example, everyone has seen the filter on the Amazon, Flipkart, etc. websites to filter the products according to different criteria. To create something like that, either we can get the filtered data from the database directly, or we can get the whole data and filter at the frontend side from the array of the products, and it depends on some criteria such as database size, performance, etc. Use the ...

Read More

How to invoke methods of a particular class in TypeScript?

Shubham Vora
Shubham Vora
Updated on 16-Dec-2022 7K+ Views

In this tutorial, users will learn to invoke a particular class method in TypeScript. The class is the basic concept of object-oriented programming. In simple terms, it contains member variables and methods we can access by creating the object of that particular class. So, class is the blueprint of the objects we create for that particular class. The class can contain the functions in TypeScript, and we can also call them to the method. So, users need to learn to access and invoke the method of the particular class. Invoking the method of a particular class in TypeScript In TypeScript, ...

Read More
Showing 71–75 of 75 articles
« Prev 1 4 5 6 7 8 Next »
Advertisements