New to Kendo UI for Angular? Start a free 30-day trial
distinct<T>
Reduces the provided array so it contains only unique values.
ts
import { distinct } from '@progress/kendo-data-query';
const data = [
{ name: "Pork", category: "Food", subcategory: "Meat" },
{ name: "Pepper", category: "Food", subcategory: "Vegetables" },
{ name: "Beef", category: "Food", subcategory: "Meat" }
];
const result = distinct(data, "subcategory");
// output:
// result => [
// { name: "Pork", category: "Food", subcategory: "Meat" },
// { name: "Pepper", category: "Food", subcategory: "Vegetables" }
// ];
Parameters
data T[]
The array that will be reduced.
comparer Comparer | string
An optional custom comparer function or the field name that will be used for comparison.
Returns
T[] - The reduced data.