Function intersperse

  • Return an array with the separator interspersed between each element of the input array.

    Type Parameters

    • A
    • S

    Parameters

    • array: A[]

      Array to intersperse.

    • separator: S

      Value to insert.

    Returns (A | S)[]

    intersperse(["a", "b", "c"], "x"); // => ["a", "x", "b", "x", "c"]