.add() - DarthJDG/Mangler.js GitHub Wiki

Adds items or arrays of items to the mangler object.

.add(item[, item...])
Parameter Type Default Description
item Any
Array
Any value, object or array of items to add. The method accepts any number of parameters.

Returns

Returns a reference to the mangler object itself for chaining.


If item is an array, all items from the array are added separately. In all other cases, item is pushed to the .items[ ] array as is. To avoid unwrapping arrays, use the .push() method.

Differences between .add() and .push()

a = ['A', 'B', 'C'];
b = ['D', 'E', 'F'];

m1 = Mangler().add(a, b);
m2 = Mangler().push(a, b);

/*
    m1.items = ['A', 'B', 'C', 'D', 'E', 'F']
    m2.items = [['A', 'B', 'C'], ['D', 'E', 'F']]
*/
⚠️ **GitHub.com Fallback** ⚠️