手记

reduce函数数组求和

//数组求和

this.tableData2 = [100,200,13,5,45,767,88.43,0],
total = this.tableData2.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);



1人推荐
随时随地看视频
慕课网APP