js-deep-merge
v1.0.4
Published
Deep merging for Objects and Arrays
Downloads
7
Readme
JS Deep Merge
Object.deepMerge(target, source)
Array.deepMerge(target, source)
A tiny supportive script that enables deep JavaScript Object and Array merging.
Object
The script performs a complete deep merge and merges arrays with the Array merging script.
var object1 = { key1: value1 };
var object2 = { key2: value2 };
Object.deepMerge(object1, object2); // { key1: value1, key2: value2 }
Array
The script handles Arrays as Associative Arrays so the index is taken as the index and therefore replaced if the array to merge has a same index.
var array1 = [ 'key1', 'key2' ];
var array2 = [ 'key3' ];
Array.deepMerge(array1, array2); // [ 'key3', 'key2' ]