The for loop is the most compact form of looping and includes the following three important parts:

The loop initialization where we initialize our counter to a starting value. The initialization statement is executed before the loop begins.

The test statement which will test if the given condition is true or not. If condition is true then code given inside the loop will be executed otherwise loop will come out.

The iteration statement where you can increase or decrease your counter.

You can put all the three parts in a single line separated by a semicolon.

Syntax:

for (initialization; test condition; iteration statement){
 Statement(s) to be executed if test condition is true
}

Example:

<html>
<body>
<script type="text/javascript">
var count;
for(count = 0; count < 10; count++){
  document.write("Number : " + count );
  document.write("<br />"); }
</script>
</body>
</html>

This is the result:

 

 

Next

Chapter 15 - JavaScript While Loop

Recent Topics
Subject
Post Reply
Open
Recent
Report an issue with the taxi rate calculation program
By flook Tue 21 Feb 2023 11:59 am Board English Language
0
1569
Tue 21 Feb 2023 11:59 am By flook View Topic Report an issue with the taxi rate calculation program
Report a problem using the Program for calculating land price per unit
By Thanapoom1514 Mon 20 Feb 2023 10:54 am Board English Language
0
2867
Mon 20 Feb 2023 10:54 am By Thanapoom1514 View Topic Report a problem using the Program for calculating land price per unit
Report a problem using the total land price calculation program
By Thanapoom1514 Mon 20 Feb 2023 10:24 am Board English Language
0
1448
Mon 20 Feb 2023 10:24 am By Thanapoom1514 View Topic Report a problem using the total land price calculation program
Report a problem using the Metabolic rate calculation program (BMR) program
By Tookta Mon 13 Feb 2023 4:35 pm Board English Language
0
2593
Mon 13 Feb 2023 4:35 pm By Tookta View Topic Report a problem using the Metabolic rate calculation program (BMR) program
Report a problem using the temperature converter program
By Thanapoom1514 Mon 13 Feb 2023 10:18 am Board English Language
0
2105
Mon 13 Feb 2023 10:18 am By Thanapoom1514 View Topic Report a problem using the temperature converter program
Report a problem using the program for calculating planting area
By Thanapoom1514 Mon 13 Feb 2023 10:17 am Board English Language
0
1524
Mon 13 Feb 2023 10:17 am By Thanapoom1514 View Topic Report a problem using the program for calculating planting area
Report a problem using the program sport line up
By Thanapoom1514 Mon 13 Feb 2023 10:14 am Board English Language
0
1876
Mon 13 Feb 2023 10:14 am By Thanapoom1514 View Topic Report a problem using the program sport line up
Report a problem using the program Character Counter
By Tookta Sat 11 Feb 2023 9:46 am Board English Language
0
1842
Sat 11 Feb 2023 9:46 am By Tookta View Topic Report a problem using the program Character Counter
Report a problem using the QRcode PromptPay Payment program
By Tookta Wed 08 Feb 2023 11:01 am Board English Language
0
810
Wed 08 Feb 2023 11:01 am By Tookta View Topic Report a problem using the QRcode PromptPay Payment program
AWS Training in Chennai
By infocus619 Mon 28 Nov 2022 2:30 pm Board English Language
0
638
Mon 28 Nov 2022 2:30 pm By infocus619 View Topic AWS Training in Chennai
not updating Joomla 2.5
By vitaliy.k Wed 23 Nov 2022 11:37 am Board English Language
4
1076
Thu 15 Dec 2022 8:02 pm By mindphp View Topic not updating Joomla 2.5
介绍 MZC 插入 System MZC Multi Shop Close 对于设置各店铺的开闭时间。
By alfie8522 Fri 22 Jul 2022 1:46 pm Board Chinese Language - 简体中文
1
5722
Thu 04 May 2023 2:55 am By Anonymous View Topic 介绍 MZC 插入 System MZC Multi Shop Close 对于设置各店铺的开闭时间。
介绍 MZC 模块 Shops 显示用于更改购买商店的商店选项。
By alfie8522 Thu 21 Jul 2022 1:31 pm Board Chinese Language - 简体中文
0
1490
Thu 21 Jul 2022 1:31 pm By alfie8522 View Topic 介绍 MZC 模块 Shops 显示用于更改购买商店的商店选项。
介绍 MZC 模块 Filter 产品过滤器以找到所需的产品。
By alfie8522 Mon 18 Jul 2022 1:16 pm Board Chinese Language - 简体中文
0
1088
Mon 18 Jul 2022 1:16 pm By alfie8522 View Topic 介绍 MZC 模块 Filter 产品过滤器以找到所需的产品。
Online Essay Writing Service Help UK
By eleanorellis Sat 16 Jul 2022 5:58 pm Board English Language
2
1507
Sun 16 Oct 2022 1:46 am By SirenSong21 View Topic Online Essay Writing Service Help UK
介绍 MZC 模块 Products tags name 对于显示产品名称标签。
By alfie8522 Wed 13 Jul 2022 12:49 pm Board Chinese Language - 简体中文
0
1000
Wed 13 Jul 2022 12:49 pm By alfie8522 View Topic 介绍 MZC 模块 Products tags name 对于显示产品名称标签。
介绍 MZC 模块 Cart Ext 用户的购物车,其中包含更多详细信息,而不仅仅是产品的价格。
By alfie8522 Tue 12 Jul 2022 12:04 pm Board Chinese Language - 简体中文
0
913
Tue 12 Jul 2022 12:04 pm By alfie8522 View Topic 介绍 MZC 模块 Cart Ext 用户的购物车,其中包含更多详细信息,而不仅仅是产品的价格。
介绍 MZC 模块 Top Rating 对于显示从评论中获得最高评级的产品。
By alfie8522 Mon 11 Jul 2022 10:58 am Board Chinese Language - 简体中文
0
944
Mon 11 Jul 2022 10:58 am By alfie8522 View Topic 介绍 MZC 模块 Top Rating 对于显示从评论中获得最高评级的产品。
介绍 MZC 模块 Product Slide 创建幻灯片以在您的网站上显示产品。
By alfie8522 Sat 09 Jul 2022 4:35 pm Board Chinese Language - 简体中文
0
923
Sat 09 Jul 2022 4:35 pm By alfie8522 View Topic 介绍 MZC 模块 Product Slide 创建幻灯片以在您的网站上显示产品。
介绍 MZC Ajax Search 帮助按类别查找产品 ,关键词 ,无需刷新页面。
By alfie8522 Sat 09 Jul 2022 9:53 am Board Chinese Language - 简体中文
0
933
Sat 09 Jul 2022 9:53 am By alfie8522 View Topic 介绍 MZC Ajax Search 帮助按类别查找产品 ,关键词 ,无需刷新页面。