标签:while pre arch targe console 数组 var log get
for (语句 1; 语句 2; 语句 3) { 被执行的代码块; }
var arr = [1, 2, 3, 4, 5]; (function(){ for(var i = 0; i < arr.length; i++){ console.log(arr[i]); //1 2 3 4 5 } })();
(function(){ for(var i = 0, max = arr.length; i < max; i++){ console.log(arr[i]); //1 2 3 4 5 } })();
i += 1
或i = i+1
比i++
快(function(){ for(var i = 0, max = arr.length; i < max; i += 1){ console.log(arr[i]); //1 2 3 4 5 } })();
(function(){ for(var i = arr.length; i--;){ console.log(arr[i]); //5 4 3 2 1 } })(); (function(){ var i = arr.length; while(i--){ console.log(arr[i]); //5 4 3 2 1 } })();
标签:while pre arch targe console 数组 var log get
原文地址:http://www.cnblogs.com/mazey/p/7267419.html