Javascript examples for Statement:for
Omit the first parameter in for loop and set values before the loop starts
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w ww. ja v a 2 s . co m*/ var cars = ["a","b","c","d","e"]; var i = 2; var len = cars.length; var text = ""; for (; i < len; i++) { text += cars[i] + "<br>"; } document.getElementById("demo").innerHTML = text; } </script> </body> </html>