Defu Vs Lodash._merge: Key Differences In Object Merging
Defu vs lodash._merge: Defu assigns default properties recursively, but doesn't merge arrays. lodash._merge merges objects and arrays recursively. Key difference: Defu overwrites existing array items, while lodash._merge preserves them.
In one of the previous week’s articles, I noticed Defu is used in unbuild source code to merge objects. This got me wondering how this is different to lodash._merge. In this article, we will look at their differences. I created a Codesandbox repository for the purposes of this article. Let’s get started. lodash._merge Below is definition picked from official docs. This method is like _.assign except that it recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. Source properties that resolve to undefined are skipped if...