Skip to content

Chaining map and reverse returns unmodified array. #890

@evanrs

Description

@evanrs

When upgrading to 3.0.0 I had trouble with a code block very similar to

_([{a: 1}, {a: 2}, {a: 3}, null])
  .map(function(v) { return v && v.a })
  .compact()
  .reverse()
  .value()

resulting in [1, 2, 3, null], where I had expected [3, 2, 1].

Comparing this example with the following you'll see that while the values can change the order and index will remain the same.

// returns [1, 2, 3, null], expected [null, 3, 2, 1]
_([1, 2, 3, null]).map(_.identity).reverse().value()

// returns [1, 2, 3, null], expected [3, 2, 1]
_([1, 2, 3, null]).map(_.identity).compact().reverse().value()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions