标签:
1 // Example of a for loop: 2 3 for (var counter = 1; counter < 6; counter++) { 4 console.log(counter); 5 }
a. store lists of data
b. can store different data types at the same time
c. are ordered so the position of each piece of data is fixed
1 // Let‘s print out every element of an array using a for loop 2 3 var cities = ["Melbourne", "Amman", "Helsinki", "NYC"]; 4 5 for (var i = 0; i < cities.length; i++) { 6 console.log("I would like to visit " + cities[i]); 7 }
标签:
原文地址:http://www.cnblogs.com/elewei/p/5645628.html