Function containsDuplicateValues

Returns true if array contains duplicate values.

containsDuplicateValues(['a','b','a']); // True
containsDuplicateValues([
{ name: 'Apple' },
{ name: 'Apple' }
]); // True

Uses JSON.toString() by default to compare values.

See also:

  • Type Parameters

    • V

    Parameters

    • array: V[] | readonly V[]

      Array to examine

    • keyFunction: ((itemToMakeStringFor: V) => string) = ...

      Function to generate key string for object, uses JSON.stringify by default.

        • (itemToMakeStringFor): string
        • A default converter to string that uses JSON.stringify if its an object, or the thing itself if it's a string

          Parameters

          • itemToMakeStringFor: V

          Returns string

    Returns boolean