{hero}

DataTable.util.unique()

Since: DataTables 2.0

Get all unique items from an array.

Description

DataTables often needs to get an array of items which are unique in that array. We've exposed this functionality as a utility method so it can be used by extensions and plug-ins for DataTables.

Note that it does not mutate the original array passed in. Rather a new array is created and the unique values assigned to the array.

Type

function unique( src )

Description:

Get unique values from an array.

Returns:

Array with unique values

Example

Get unique values from an array:

let unique = DataTable.util.unique([1, 1, 2, 3, 1]);

// unique is: [1, 2, 3]