- for循环遍历
let array = [‘a‘,‘b‘,‘c‘]; for (let i = 0;i < array.length;i++){ console.log(array1[i]); // a b c }
- 用for in的方遍历数组
for(let index in array) { console.log(index,array[index]); };
- JavaScript 提供了 foreach() map() 两个可遍历 Array对象的方
forEach和map用法类似,都可以遍历到数组的每个元素,而且参数一致;
array.forEach(v=>{ console.log(v); }); array.forEach(function(v){ console.log(v); });
valueList.forEach(element => { console.log(element + " is exist in the list"); let label = this.filterLabel.replace(/\{0\}/g, element); let result = $(label).isDisplayed(); expect(result).to.equal(false); });
原文地址:https://www.cnblogs.com/cherry1130/p/12426471.html
时间: 2024-10-11 02:30:21