我正在 Firefox 中进行测试,它正在记录 OP 所说的内容。这是我的看法。
变量计数器 = 1;
1 is it <= 10 yes, print add 1
2 is it <= 10 yes, print add 1
3 is it <= 10 yes, print add 1
4 is it <= 10 yes, print add 1
5 is it <= 10 yes, print add 1
6 is it <= 10 yes, print add 1
7 is it <= 10 yes, print add 1
8 is it <= 10 yes, print add 1
9 is it <= 10 yes, print add 1
10 is it <= 10 yes, print add 1
11 <-- prints it.
while 循环在传入时知道“计数器”,而不是在声明“之后”或在循环内。它没有反向引用。所以还是得再过一遍。
before: 1
after: 2
before: 2
after: 3
before: 3
after: 4
before: 4
after: 5
before: 5
after: 6
before: 6
after: 7
before: 7
after: 8
before: 8
after: 9
before: 9
after: 10
before: 10
after: 11