Introduction
Nested For loop means "A For loop inside another For loop". The syntax is as follows:
- For(Initialization; Condition; Increment / Decrement) {
- For(Initialization; Condition; Increment / Decrement) {}
- }
When the condition of the first for loop is true, execution proceeds to the second loop and the second loop continues until the condition of the second loop becomes false then it will go to the first loop again and the process continues. To see how it works let's use the following steps.
Step 1
Open Visual Studio 2012 and click on "File" -> "New" -> "Project...".
Step 2
A window is opened. In it select HTML Application for TypeScript under Visual C# and then give the name of your application that you want to give and then click ok.
Step 3
The TypeScript file contains the app.ts file (TypeScript file) , app.js file (Javascript file ) and the default.htm file (HTML file). In this open the app.ts file.
Step 4
Write the following code in this app.ts file:
Step 7
Now run the application and the output will look like:
Summary
In this article, I explained how to use a nested for loop in TypeScript.