Skip to content

Deep clone map with nested maps. #2137

@sergej-s

Description

@sergej-s

Hello,

I'm stuck with issue of deep cloning map which contains other maps. It seems that values of nested map are not cloned. Please look at the next code:

let m1 = new Map([
  [1, {a: '1'}],
  [2, {b: '2'}]
])

let m2 = new Map([
  [3, {c: '3'}],
  [4, {d: '4'}]
])

let m3 = new Map([
  ['m1', m1],
  ['m2', m2]
])

let m4 = _.cloneDeep(m3);

console.log(m4===m3); // log false - Ok
console.log(m4.get('m1')===m3.get('m1')); // log true - but should be false also`

Is this bug or am I doing something wrong?

Tested with lodash 4.6.1 http://jsbin.com/jubiwaquma/1/edit?html,js,output

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