ES6 for everyone - 22. for of loop

// demo-01

const items = ['a', 'b', 'c'];
for(const [i, item] of items.entries()) {
  console.log(`${item} is the ${i} item`);
}
// demo-02

function addUpNumbers() {
  let total = 0;
  for(let num of arguments) {
    total += num;
  }
  return total;
}
var res = addUpNumbers(1, 3, 5, 7, 9);
console.log(res);

你可能感兴趣的:(ES6 for everyone - 22. for of loop)