for(let value of target){}循环遍历
1.遍历数组
2.遍历Set
3.遍历Map
4.遍历字符串
5.遍历伪数组
例:
//数组去重方法
let arr = [1,2,3,4,5,5,6,2];
let arr1 = arr;
arr = [];
let set=new Set(arr1);
for(let i of set){
arr.push(i);
}
console.log(...arr);
let arr3 = [1,2,3,4,5,5,6,2];
let set2 = new Set(arr3);
console.log(...set2);
let btns = document.getElementsByTagName("button");
for(let j of btns){
console.log(j);
}