Skip to content

Multiple arguments overwrites values in arguments #18

@fiLLLip

Description

@fiLLLip

Using Object.assign with an empty target, only the target is changed, not the inputs/arguments. Usign assign-deep, the inputs also get overwritten. Is this expected behaviour? I did not expect this.

var assignDeep = require("assign-deep")

var o1 = { a: 1, b: 1, c: {a: 1} };
var o2 = { b: 2, c: {a:2} };
var o3 = { c: {a:3} };

console.log(assignDeep({}, o1, o2, o3));
// Expected output: Object {a: 1, b: 2, c: Object {a: 3}}
console.log('o1', o1);
// Expected output: Object {a: 1, b: 1, c: Object {a: 1}}
// Actual output: Object {a: 1, b: 1, c: Object {a: 3}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions