• Returns the array that contains all the given elements at the index of the source array

    Type Parameters

    • E

    Parameters

    • Optionalarray: null | E[]

      the array to inspect

    • Optionalindex: number

      the index to insert, negative or greater than the length of source array, means at the end of the source array

    • Optionalelements: null | E[]

      the elements to insert

    Returns E[] | undefined | null

    the array that contains all the given elements at the index of the source array

    insert(['foo', 'bar'], -1, ['hello', 'world']);    // ['foo', 'bar', 'hello', 'world']
    insert(['foo', 'bar'], 0, ['hello', 'world']); // ['hello', 'world', 'foo', 'bar']
    insert(['foo', 'bar'], 1, ['hello', 'world']); // ['foo', 'hello', 'world', 'bar']
    insert(['foo', 'bar'], 9, ['hello', 'world']); // ['foo', 'bar', 'hello', 'world']