pols-utils - v5.9.0
    Preparing search index...

    Function pushIfNotExists

    • Insert a element into an array if the element not exists.

      Parameters

      • array: unknown[]

        The target array.

      • element: unknown

        The element to insert.

      Returns boolean

      It returns true if the element was inserted.

      const mynumbers = [0, 1, 2]
      console.log(PUtilsArray.distinct(mynumbers, 3)) // true
      console.log(PUtilsArray.distinct(mynumbers, 3))