This statement can be said to be quite convenient, especially the huge data loop is an artifact! But the challenge is to understand where the boundaries are.
Let's talk about the syntax for the For loop.
for (initial conditions; condition judgment; condition change) {
The Code of the Loop
}
Execution order:
1. First condition
2. Starting condition judgment
3. If set up, execute the block of code to loop
4. Changes in conditions
2,3,4,2,3,4 ....
Until the condition is judged not to be true, the entire cycle ends
Attention:
The conditional judgment has always been true, and the loop continues to be executed, called the Dead loop.
Be sure to write two semicolons in a for loop
For the order of execution, it is certain to recognize, otherwise the number of cycles may be the same as expected, but also note that the best not to let the computer into the cycle of death, unless you are a warrior, the browser will be stuck, minutes hanging off, so that, as a serious programmer to be kind to the browser this good friend Wow!!!
Do you remember the 99 multiplication table? Yes, we did it with a for loop, and some of the code is as follows:
<script>var box = document.getElementById (' box ');//Customize a variable str, initially null character var str = ';//Use the For loop to determine a total of 9 columns, which generates nine div.//I is the number of columns, J is the number of rows for (var i = 1; i < i++) {//STR is pieced together str + = ' <div> ';//The number of columns in each column is constant, the number of rows starts from I to 9for (var j = i; J < J + +) {var n = i + ' x ' +j + ' = ' +i*jstr + = ' <span> ' +n+ ' </span> '}str + = ' </div> '}box.innerhtml = str;& Lt;/script>
If using HTML+CSS can also be made, but JS relative to write less characters, otherwise 81 small squares fill different formulas, that must be the whole to se years ah.
Using the For loop alone is too tedious, so I made a If + for small east, a V-shaped small square box, the most distinctive place is to find the law, positioning each small box left,top value, together to see:
<! DOCTYPE html>Now realized that the original mathematical law is really not a white learning, although the purchase of food with no calculus, use not to find the law, but in the use of computers, mathematics is really too important, ah ~ to re-pay attention up,.
Js-for Loop Statements