码迷,mamicode.com
首页 > Web开发 > 详细

JS - LOOPs

时间:2016-07-06 09:56:27      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

For Loop Example

1 // Example of a for loop:
2 
3 for (var counter = 1; counter < 6; counter++) {
4     console.log(counter);
5 }

 

Arrays

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 }

 

JS - LOOPs

标签:

原文地址:http://www.cnblogs.com/elewei/p/5645628.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!