Combines the values of one or more arrays, removing duplicates. Compares based on a string representation of object. Uses a Set to avoid unnecessary comparisons, perhaps faster than uniqueDeep.
uniqueDeep
const v = Arrays.unique([ [1, 2, 3, 4], [ 3, 4, 5, 6] ]);// [ 1, 2, 3, 4, 5, 6] Copy
const v = Arrays.unique([ [1, 2, 3, 4], [ 3, 4, 5, 6] ]);// [ 1, 2, 3, 4, 5, 6]
A single array can be provided as well:
const v = Arrays.unique([ 1, 2, 3, 1, 2, 3 ]);// [ 1, 2, 3 ] Copy
const v = Arrays.unique([ 1, 2, 3, 1, 2, 3 ]);// [ 1, 2, 3 ]
By default uses JSON.toString() to compare values.
See also:
Array (or array of arrays) to examine
Function to convert values to a string for comparison purposes. By default uses JSON formatting.
A default converter to string that uses JSON.stringify if its an object, or the thing itself if it's a string
Combines the values of one or more arrays, removing duplicates. Compares based on a string representation of object. Uses a Set to avoid unnecessary comparisons, perhaps faster than
uniqueDeep
.A single array can be provided as well:
By default uses JSON.toString() to compare values.
See also: