Microsoft®
JScript for Statement |
Language Reference Version 1
|
Executes a block of statements for as long as a specified condition is true.
for (initialization; test; increment)
statementThe for statement syntax has these parts:
Part Description initialization An expression. This expression is executed only once, before the loop is executed. test A Boolean expression. If test is true, statement is executed. If test if false, the loop is terminated. increment An expression. The increment expression is executed at the end of every pass through the loop. statement The statement to be executed if test is true. Can be a compound statement.
You usually use a for loop when the loop is to be executed a specific number of times. The following example demonstrates one.for (var i = 0; i < 10; ++i) { console.log("i is ("+i+")"); }See the continue Statement. This is especially useful in combination with the Label Statement. Example:
forLoop1: //The first for statement is labeled "forLoop1" for (i = 0; i < 3; ++i) { forLoop2: //The second for statement is labeled "forLoop2" for (j = 0; j < 3; ++j) { if (i === 1 && j === 1) { continue forLoop1 } console.log('i = ' + i + ', j = ' + j) } } // 'i = 1, j - 1' will NOT print, all other combinations from 0 to 2 will.
© 1997 by Microsoft Corporation. All rights reserved.
See also:
file: /Techref/inet/iis/jscript/htm/js752.htm, 3KB, , updated: 2021/3/20 10:47, local time: 2024/11/21 05:27,
3.138.134.221:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/techref/inet/iis/jscript/htm/js752.htm"> for Statement</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.