const iterable = ['mini', 'mani', 'mo']; for (const value of iterable) { console.log(value); } // Output: // mini // mani // mo
Maps(映射)
1 2 3 4 5 6 7 8 9
const iterable = newMap([['one', 1], ['two', 2]]); for (const [key, value] of iterable) { console.log(`Key: ${key} and Value: ${value}`); } // Output: // Key: one and Value: 1 // Key: two and Value: 2
Set(集合)
1 2 3 4 5 6 7 8
const iterable = newSet([1, 1, 2, 2, 1]); for (const value of iterable) { console.log(value); } // Output: // 1 // 2
String(字符串)
1 2 3 4 5
constiterable = 'javascript'; for (const value of iterable) { console.log(value); }