filter out duplicates from an array in TypeScript

filter out duplicates from an array in TypeScript

code:

 export function isUnique{T}(value: T, index: number, self: T[]): boolean {  
   return self.indexOf(value) === index;  
 }  

where {T} should be < T >

usage:

 const uniqueItems = items.filter(isUnique);  


Comments