In this tutorial, you will learn how to create a loop using the TypeScript while statement. Introduction to the TypeScript while statement The while statement allows you to create a loop that executes a block of code as long…
In this tutorial, you will learn about the TypeScript for loop statement that executes a piece of code repeatedly. Introduction to the TypeScript for statement The following shows the syntax of the TypeScript for loop statement: The for loop statement creates…
In this tutorial, you will about the TypeScript switch…case statement. Introduction to TypeScript switch case statement The following shows the syntax of the switch…case statement: How it works: First, the switch…case statement evaluates the expression. Then, it searches for the first case clause whose…
In this tutorial, you will learn about the TypeScript if…else statement. TypeScript if statement An if statement executes a statement based on a condition. If the condition is truthy, the if statement will execute the statements inside its body: For example,…
In this tutorial, you will learn about the Type inference in TypeScript. Type inference describes where and how TypeScript infers types when you don’t explicitly annotate them. Basic type inference When you declare a variable, you can…
In this tutorial, you will learn about the TypeScript string literal types that define a type that accepts a specified string literal. The string literal types allow you to define a type that accepts only…
In this tutorial, you will learn about the TypeScript union type that allows you to store a value of one or several types in a variable. Introduction to TypeScript union type Sometimes, you will run…