Way 2 Help

Array helpers, so you can get very fast your data from the array.
here an example array.
var exampleArray = [
{
id: 0,
name: 'John',
age: 93,
city: 'Patmos',
},
{
id: 1,
name: 'Peter',
age: 62,
city: 'Rome',
},
{
id: 2,
name: 'Luke',
age: 84,
city: 'Boeotia'
},
{
id: 2,
name: 'Paul',
age: 62,
city: 'Rome'
},
];
multisort
Sort an array with objects by the key of the object.
By default it is asc, and you can set desc as an optional value to the 2nd parameter.
exampleArray.multisort('age', 'desc');
[
{
id: 0,
name: 'John',
age: 93,
city: 'Patmos',
},
{
id: 2,
name: 'Luke',
age: 84,
city: 'Boeotia'
},
{
id: 1,
name: 'Peter',
age: 62,
city: 'Rome',
},
{
id: 2,
name: 'Paul',
age: 62,
city: 'Rome'
},
]
multifilter
Filters the array for a given key and value.
If the 3th parameter is true, excluding a given key and value.
exampleArray.multifilter('age', '62');
[
{
id: 1,
name: 'Peter',
age: 62,
city: 'Rome',
},
{
id: 2,
name: 'Paul',
age: 62,
city: 'Rome'
},
]
exampleArray.multifilter('age', '62', true);
[
{
id: 0,
name: 'John',
age: 93,
city: 'Patmos',
},
{
id: 2,
name: 'Luke',
age: 84,
city: 'Boeotia'
},
]
multikey
Plucks the given keys from the array.
exampleArray.multikey(['name', 'age']);
[
{
name: 'John',
age: 93
},
{
name: 'Peter',
age: 62
},
{
name: 'Luke',
age: 84
},
{
name: 'Paul',
age: 62
},
]
intersect
Computes the intersection of arrays.
Returns an array containing the values that are present in all the arrays.
If the 2nd parameter is true, the 1st parameter can contain multiple arrays.
var a = ['John', 'Peter', 'Luke'];
var b = ['Peter', 'Luke', 'Paul'];
var c = ['Peter', 'Luke', 'John'];
a.intersect(b);
['Peter', 'Luke']
a.intersect([b c], true);
['Peter', 'Luke']
diff
Computes the difference of arrays.
Compares the array values, and return all values from array a that arent present in array b.
If the 2nd parameter is true, it return all values that are not present in any of the arrays.
var a = ['John', 'Peter', 'Luke'];
var b = ['Peter', 'Luke', 'Paul'];
a.diff(b);
['John']
a.diff(b, true);
['John', 'Paul']
unique
Removes duplicate values from an array.
Takes the array and returns a new array without duplicate values.
var a = ['John', 'Peter', 'Luke', 'Peter', 'Luke', 'Paul'];
a.unique();
['John', 'Peter', 'Luke', 'Paul']
pushIfNotExists
Only push the value to the array if the value doesnt exists in the array.
Returns the new length property of the object upon which the method was called.
var a = [];
a.pushIfNotExists('John');
['John']
a.pushIfNotExists('Peter');
['John', 'Peter']
a.pushIfNotExists('John');
['John', 'Peter']