Name

for — NN 2 IE J1 ECMA 1

Synopsis

A construction that allows repeated execution of statements, usually for a controlled number of times.

Syntax

for ([initExpression]; [condition]; [updateExpression]) {
    statements
}

Example

var userEntry = document.forms[0].entry.value
var oneChar
for (var i = 0; i < userEntry.length; i++) {
    oneChar = userEntry.charAt(i)
    if (oneChar < "0" || oneChar > "9") {
        alert("The entry must be numerals only.")
    }
}

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.