object-join

Merge two objects recursively into a new object

object-join

Merge two objects recursively into a new object.

$ npm i --save object-join
/**
 * Initialize
 */
 
var objectJoin = require('object-join');
 
/**
 * Declare objects
 */
 
var obj1 = {foo: 'bar'};
var obj2 = {bin: 'baz'};
 
/**
 * Merge objects
 */
 
var newObject = objectJoin(obj1, obj2);
// => {foo: 'bar', bin: 'baz'}; 

Merges two objects into a new object. Takes {Object} obj1 and {Object} obj2 as arguments. If duplicate keys exist, {Object} obj2's keys take presedence.

var newObject = objectJoin(obj1, obj2);
// => {foo: 'bar', bin: 'baz'}; 

MIT © Yoshua Wuyts