🌐 AI搜索 & 代理 主页
Skip to content

meanBy returning NaN on empty lists is error prone #5901

@tran-simon

Description

@tran-simon

_.meanBy([], 'test') will return NaN

This behavior is not currently documented, meaning that users might not know that it could return NaN.

Possible solutions:

  • Make meanBy return undefined instead of NaN, meaning that users using TypeScript will have to handle that case
  • Improve the documentation to warn users that they mustn't assume that the returned value is a valid number

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions