ReferenceelementAt
Reference · 59
elementAt
elementAt
Takes the value at an index and completes the stream.
Signature
elementAt(index: number, defaultValue?: D): OperatorFunction
What it does
Counts values from zero. When it reaches the target index, it emits the value and ends the subscription.
When to use
Tests, protocols with a fixed message number, picking a specific step from a finite sequence.
Gotcha
If the index is never reached and no defaultValue is given, the stream fails with ArgumentOutOfRangeError.
See also
first, last, skip
script.ts
CONSOLE · Console output
Hit Run to see the result...