According to the lodash docs, _.extend(object, [sources])
mutates the first parameter.
var dest = {
a: 1
};
_.extend(dest, {
b: 2
});
// expect { "a": 1, "b": 2 }
// actual { "a": 1, "b": 2 }
console.log(dest);
<script src="https://cdn.jsdelivr.net/lodash/4.15.0/lodash.js"></script>
When using lodash/fp, this is not the case (argument order is unchanged):
var dest = {
a: 1
};
_.extend(dest, {
b: 2
});
// expect { "a": 1, "b": 2 }
// actual { "a": 1 }
console.log(dest);
<script src="https://cdn.jsdelivr.net/lodash/4.15.0/lodash.js"></script>
<script src="https://cdn.jsdelivr.net/lodash/4.15.0/lodash.fp.js"></script>
This is problematic as I have a lot of code that mutates this
. Is this a bug in lodash and is there a workaround?