for in 和 for of的区别
for in 和 for of的区别是:in 是遍历对象,of是遍历值
let set = new Set(['red', 'green', 'blue']); for (let x of set) { console.log(x); } red green blue
let set = new Set(['red', 'green', 'blue']); for (let x in set) { console.log(x); } undefined
for in 和 for of的区别是:in 是遍历对象,of是遍历值
let set = new Set(['red', 'green', 'blue']); for (let x of set) { console.log(x); } red green blue
let set = new Set(['red', 'green', 'blue']); for (let x in set) { console.log(x); } undefined