标签:
//数组循环
var a = [1, 2, 3, 4, 5, 6];
for (var i = 0, l = a.length; i < l; i++) {
console.log(a[i]);
}
for (var i in a) {
console.log(a[i]);
}
a.forEach(function (v, i, a) {
a[i] = v + 1;
console.log(a[i]);
});
a.map(function (x) {
return x + 1
});
//枚举值的遍历
var o = {x: 1, y: 2, z: 3};
for (p in o) {
console.log(o[p]);
}
标签:
原文地址:http://www.cnblogs.com/chencai/p/4701533.html