美文网首页
ES6 for everyone - 22. for of lo

ES6 for everyone - 22. for of lo

作者: awesome_lewis | 来源:发表于2017-09-03 22:16 被阅读22次
    // 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 lo

          本文链接:https://www.haomeiwen.com/subject/idxsjxtx.html