@unikue/ts-lang-utils
    Preparing search index...

    Function add

    Utilities for array

    David Hsing

    • Returns the array that adds the given element

      Type Parameters

      • E

      Parameters

      • Optionalarray: E[] | null

        The arrays to inspect

      • Optionalelement: E | null

        The element to add

      Returns E[] | null | undefined

      the array that adds the given element

      David Hsing

      add(undefined, 'bar');    // ['bar']
      add(['foo', 'bar'], undefined); // ['foo', 'bar']
      add(['foo', 'bar'], 'world'); // ['foo', 'bar', 'world']