找回密碼
 立即註冊
查看: 1156|回復: 0

JS : .reduce() Method

[複製鏈接]

920

主題

629

回帖

3萬

積分

管理員

論壇管理員

積分
37702

最佳新人活躍會員熱心會員推廣達人宣傳達人灌水之王突出貢獻優秀版主榮譽管理論壇元老

發表於 2022-11-24 19:14:51 | 顯示全部樓層 |閱讀模式
  1. const newNumbers = [1, 3, 5, 7];

  2. const newSum = newNumbers.reduce((accumulator, currentValue) => {
  3.   console.log('The value of accumulator: ', accumulator);
  4. console.log('The value of currentValue: ', currentValue);
  5.   return accumulator + currentValue;
  6. }, 10);
  7. console.log(newSum);
複製代碼
這是 .reduce() 方法。
[發帖際遇]: 一個袋子砸在了 admin 頭上,admin 賺了 5 金錢. 幸運榜 / 衰神榜
您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|小黑屋|DD論壇 維護: Redd Design

GMT+8, 2024-5-6 00:22 , Processed in 0.027174 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表