Javascript Deep Merge Array of Objects Plugin | jQuery.extendext

javascript-deep-merge-array-of-objects

jQuery.extend with configurable behaviour for arrays that extend the native jQuery .extend() utility to allow deep (recursive) merging of JavaScript objects.

The difference is that it accepts an optional second string argument to specify how arrays are combined, such as replace, concat and extension.

merge two objects javascript, lodash deep merge, typescript deep merge objects, javascript deep merge array of objects, deepmerge vs lodash merge, deep merge npm, es6 deep merge

How to make use of it:

1. Enter jquery-extendext.js after loading the latest jQuery library.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/jquery-extendext.js"></script>

2. Merge two or more JS objects together using jquery-extensionext.js.

jQuery.extendext(deep, arrayMode, target, object1, object2);

3. Replacement mode.

var obj1 = {
    operators: ['AND', 'OR', 'XOR']
};
var obj2 = {
    operators: ['OR', 'XOR']
};
myObj = $.extendext(true, 'replace', {}, obj1, obj2);

// =>
{
  operators: ['OR', 'XOR']
}

4. Concat mode.

var obj1 = {
    operators: ['AND', 'OR', 'XOR']
};
var obj2 = {
    operators: ['OR', 'XOR']
};
myObj = $.extendext(true, 'replace', {}, obj1, obj2);

// =>
{
  operators: ['AND', 'OR', 'XOR', 'OR', 'XOR']
}

5. Extend mode.

var obj1 = {
    operators: ['AND', 'OR', 'XOR']
};
var obj2 = {
    operators: ['XOR', 'NAND']
};
myObj = $.extendext(true, 'replace', {}, obj1, obj2);

// =>
{
  operators: ['AND', 'OR', 'XOR', 'NAND']
}

6. Default mode. The same jQuery .extend() utility.

var obj1 = {
    operators: ['AND', 'OR', 'XOR']
};
var obj2 = {
    operators: ['OR', 'XOR']
};
myObj = $.extendext(true, 'replace', {}, obj1, obj2);

// =>
{
  operators: ['OR', 'XOR', 'XOR']
}

Deep Merging Of Javascript Objects, jQuery.extendext Plugin/Github


See Demo And Download

Official Website(mistic100): Click Here

This superior jQuery/javascript plugin is developed by mistic100. For extra Advanced Usages, please go to the official website.