Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_.defaultsDeeps return and mutate behaviour is inconsistent with null object #5778

Open
TechWilk opened this issue Nov 22, 2023 · 0 comments

Comments

@TechWilk
Copy link

I'm getting inconsistent behaviour in defaultsDeep between the mutated object and the return value.

let a = null;
const b = {this: "that"};

// Note: This method mutates object `a`
const c = _.defaultsDeep(a, b);

console.log(a); // null
console.log(c); // {this: "that"};

According to the docs, I would expect both a and c to be the same value once defaultsDeep has been called.

_.defaultsDeep(object, [sources])
[source](https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L12836) [npm package](https://www.npmjs.com/package/lodash.defaultsdeep)

This method is like [_.defaults](https://lodash.com/docs/#defaults) except that it recursively assigns default properties.

Note: This method mutates object.

Since

3.10.0

Arguments

object (Object): The destination object.
[sources] (...Object): The source objects.
Returns

(Object): Returns object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant