• Only add element to array if it isn't already included

    Type Parameters

    • T

    Parameters

    • array: T[]

      Target array element will be added to

    • el: T

      Unique element to add

    Returns T[]

    Array with element if it was unique

    const arr = addUnique([1, 2, 3], 3);
    console.log(arr); // Output: [1, 2, 3]

    Use ASet to create unique arrays