JavaScript Übungsaufgaben Einführung HTML Einführung  extern selfhtml
Copyright:  Holzbaur, Aalen, E-Mail an Verfasser


Zur Verwendung von autoincrement in JavaScript

 Zählschleife   Ausgabe  Code für die Berechnung  Ergebnis  Testeingabe (ändern)
 postincrement    for (x=0;x<=N;x++) alert(x)  0, 1,..., N  N 
   postincrement  for (x=0;x<=N;) alert(x++)  0, 1,..., N   N 
 präincrement    for (x=0;x<=N;++x) alert(x)  0, 2,..., N  N 
   präincrement  for (x=0;x<=N;) alert(++x)  1, 2,..., N+1  N 
 in  postincrement  for (x=0;x<=N;alert(x++))  0, 1,..., N  N 
 in  präincrement  for (x=0;x<=N;alert(++x))  1, 2,..., N+1  N 
 postincrement  postincrement for (x=0;x<=N;x++) alert(x++)  0, 2,..., N   N 
 präincrement  präincrement  for (x=0;x<=N;++x) alert(++x)  1, 3,..., N+1   N 
 postincrement  präincrement  for (x=0;x<=N;x++) alert(++x)  1, 3,..., N+1   N 
 präincrement  postincrement  for (x=0;x<=N;++x) alert(x++)  0, 2,..., N   N 
         function count()   {
         N = document.D.N.value
         for (x=0;x<=N;x++) alert(x);
     }
  <input size=2 
name="N" value=0 
onChange="count()" >