Function createArrayIterator

  • Create an iterator which is backed by the provided array, unlike a normal array iterators where the array cannot be modified function creates a shallow copy of the array using slice() so that you are free to modify the original array.

    This will still return an iterator if the provided values is null or undefined which will result in no entries.

    Type Parameters

    • T

    Parameters

    • values: T[]

      The source array to create an iterator from

    Returns Iterator<T>

    A new iterator

    Since

    0.4.2

    Example

    let cnt = 0;
    let values = [];
    iterForOf(createArrayIterator([10, 20, 5, 15]), (value) => {
    cnt++;
    values.push(value);
    });