• forEach用例


    forEach 用例

    <button onclick="summyFunction()">点我</button>
    <script> var sum = 0; var numbers = [65, 44, 12, 4]; var maskWidth = [{ value: 0 }, { value: 0 }, { value: 0 }, { value: 0 }, { value: 0 }, { value: 0 }]; var lineWidth = [{ value: 16 }, { value: 16 }, { value: 16 }, { value: 16 }, { value: 16 }, { value: 16 }]; ​ function summyFunction() { var arr3=[] numbers.forEach((item,index)=>{ sum+=item; // 求和 const arr2 = numbers[index] // 记录数组中的每个值 arr3.push(numbers[index]) // 组成新数组 push console.log('arr2',arr2) console.log('arr3',arr3) const maskWidth = this.maskWidth[index] // 记录数组中每个值 const lineWidth = this.lineWidth[index] // 记录数组中每个值 console.log('maskWidth',maskWidth) console.log('lineWidth',lineWidth) }) console.log('arr322222',arr3) demo.innerHTML = sum; } </script>

  • 相关阅读:
    C#中的Json序列化
    c#在sqlserver中使用EF框架
    Mvc中模拟模型
    localdb启动
    List泛型用法(半转载半原创)
    C#中真正的属性
    委托的简介、使用和简单事件
    类嵌套_list泛型_餐馆点菜例
    JavaIO
    JavaIO
  • 原文地址:https://www.cnblogs.com/roxanneQQyxm/p/14178849.html
Copyright © 2020-2023  润新知