• Appends the elms to the target where the elms may be an array, a single object or an iterator object

    Type Parameters

    • T

    Parameters

    • target: T[]

      The target array

    • elms: T | T[] | Iterator<T, any, undefined>

      The item, array of items an iterable or iterator object of items to add to the target

    Returns T[]

    The passed in target array

    Example

    let theArray = arrAppend([], 1);
    arrAppend(theArray, [ 2, 3, 4 ]);
    arrAppend(theArray, [ "a", "b", "c" ]);
    // theArray is now [ 1, 2, 3, 4, "a", "b", "c" ]

    Example

    // Adding a single value
    arrAppend([], undefined); // []
    arrAppend([], 0); // [ 0 ]
    arrAppend([1], undefined); // [ 1 ]
    arrAppend([1], 2); // [ 1, 2 ]

    // Adding an array
    arrAppend([], [] as number[]); // []
    arrAppend([], [0]); // [ 0 ]
    arrAppend([1], []); // [ 1 ]
    arrAppend([1], [2]); // [ 1, 2 ]

    // Adding with an iterator
    arrAppend([], ([] as number[]).values()); // []
    arrAppend([], [0].values()); // [ 0 ]
    arrAppend([1], [].keys()); // [ 1 ]
    arrAppend([1], [2].values()); // [ 1, 2 ]
    arrAppend([1], [2].keys()); // [ 1, 0 ] - 0 is from the index from the first element