• Returns the array that adds the given element

    Type Parameters

    • E

    Parameters

    • Optionalarray: null | E[]

      the arrays to inspect

    • Optionalelement: null | E

      the element to add

    Returns E[] | undefined | null

    the array that adds the given element

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