8000 A way to clone array on purpose when using chain call. · Issue #1323 · lodash/lodash · GitHub
[go: up one dir, main page]

Skip to content
A way to clone array on purpose when using chain call. #1323
Closed
@le0nik

Description

@le0nik

Hello!

In 3.10.0:

var arr = [1, 2, 3];

var arr2 = _.chain(arr)
    .slice()
    .reverse()
    .value();

console.log('arr2: ', arr2); // [3, 2, 1]

console.log('arr: ', arr); // [3, 2, 1]

// in 3.9.3 and prior to it 'console.log(arr);' would return [1, 2, 3]. The initial array would be untouched.

First i'd like to say, that it is unintuitive, undocumented(nothing in the changelog) and it broke a part of our project. Supposing, that the change was intentional(short fusion), the question is: is there a way to clone an array on purpose, considering that _.clone and _.cloneDeep aren't chainable?

Thank you!

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

      0