Interleaves the sequence with another iterable, yielding elements in alternating order.
Type of elements within the source iterable.
source
Type of elements in the second iterable.
The source iterable.
Iterable whose elements are alternated with the current sequence.
A sequence that alternates between elements from source and other.
If one sequence is longer, the remaining elements are appended after the shorter sequence is exhausted. Enumeration is deferred.
const numbers1 = [1, 3, 5];const numbers2 = [2, 4, 6];const interleaved = interleave(numbers1, numbers2).toArray();console.log(interleaved); // [1, 2, 3, 4, 5, 6] Copy
const numbers1 = [1, 3, 5];const numbers2 = [2, 4, 6];const interleaved = interleave(numbers1, numbers2).toArray();console.log(interleaved); // [1, 2, 3, 4, 5, 6]
Interleaves the sequence with another iterable, yielding elements in alternating order.