Tweakr
    Preparing search index...

    Function compact

    • Creates a new array with all falsey values removed.

      Falsey values include: false, null, 0, "", undefined, and NaN.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to filter.

      Returns T[]

      A new array with all falsey values removed.

      compact([0, 1, false, 2, "", 3]);
      // → [1, 2, 3]

      1.0.0