标签:set tin yar object each obj color span log
1.、for循环(支持break;continue;return等)
for (var index = 0; index < myArray.length; index++) { console.log(myArray[index]); }
2、forEach(不支持break;continue;return false相当于continue;)
myArray.forEach(function (value) { console.log(value); });
3、for-in(不要用来循环数组,可用来循环对象(对象可枚举的属性) )
for (var index in myObj) { console.log(myObj[index]); }
4、for-of(支持break;continue;return等。支持类数组、Map 和 Set 对象及字符串的遍历)
for (var value of myArray) { console.log(value); }
5、Object.keys(obj)、Object.values(obj)、Object.entries(obj):专门迭代对象的属性;
标签:set tin yar object each obj color span log
原文地址:https://www.cnblogs.com/zjp-zxy/p/9938729.html