js-util

Home > rc-js-util > arrayPushUnique

arrayPushUnique() function

Like Array.push but checks if the value is unique first.

Signature:

export declare function arrayPushUnique<TItem>(items: TItem[], itemToPush: TItem, getComparisonValue?: (item: TItem) => unknown): boolean;

Parameters

Parameter Type Description
items TItem[]  
itemToPush TItem  
getComparisonValue (item: TItem) => unknown (Optional)

Returns:

boolean

true if an element was pushed.

Remarks

See arrayPushUnique().