【问题标题】:what are some good scenarios in which to use reduce()? [duplicate]有哪些使用 reduce() 的好场景? [复制]
【发布时间】:2019-02-27 19:27:22
【问题描述】:

有哪些使用reduce()的好场景?我已经使用了很多 map() 和 filter(),但我不使用 reduce(),主要是 b/c 我不确定 reduce() 函数的利基/好处是什么。

【问题讨论】:

标签: javascript


【解决方案1】:

主要是,您必须(哈哈!)减少初始数组到单个元素,而其他方法也可能返回一个数组,其长度可以大于 1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-06
    • 2012-10-24
    • 1970-01-01
    • 2021-09-12
    相关资源
    最近更新 更多