Skip to content

Latest commit

 

History

History
31 lines (18 loc) · 613 Bytes

File metadata and controls

31 lines (18 loc) · 613 Bytes

for...of

功能

逐一展開,像 spread syntax(...) 。

The for...of statement creates a loop iterating over iterable objects, including: built-in String, Array, array-like objects (e.g., arguments or NodeList), TypedArray, Map, Set, and user-defined iterables.

for...of

範例

const iterable = [10, 20, 30];

for (let value of iterable) {
  value += 1;
  console.log(value);
}

// 11
// 21
// 31

console.log("---");
console.log(iterable); // [10, 20, 30]