Skip to content

merge.recursive doesn't seem to modify non-object properties #18

@mikealeonetti

Description

@mikealeonetti

Please consider the following code:

var a = { "debug" : true, "hagemashi" : "yasashii", "okuritai" : {
        "koto" : "ichi",
        "mono" : "ni"
    }
};
console.log( a );
var b = { "debug" : false, "hagemashi" : "yasashikunai", "okuritai" : {
        "koto" : "san",
        "mono" : "shi"
    }
};
console.log( merge.recursive( false, a, b ) );

console.log( a );

Outputs

{ debug: true,
  hagemashi: 'yasashii',
  okuritai: { koto: 'ichi', mono: 'ni' } }
{ debug: false,
  hagemashi: 'yasashikunai',
  okuritai: { koto: 'san', mono: 'shi' } }
{ debug: true,
  hagemashi: 'yasashii',
  okuritai: { koto: 'san', mono: 'shi' } }

I was assuming the last two outputs would be identical since the intention is to modify the original object. Am I using it incorrectly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions