Returns the element at a specified index in a sequence or null if the index is out of range. A negative index can be used to get element starting from the end.
The source iterable.
The zero-based index of the element to retrieve.
The element at the specified position in the source sequence.
const indexZero = elementAtOrDefault([1, 2, 3], 0); // Will be 1const willBeNull = elementAtOrDefault([1, 2, 3], 10); // Will be null.const last = elementAtOrDefault([1, 2, 3], -1); // 3 Copy
const indexZero = elementAtOrDefault([1, 2, 3], 0); // Will be 1const willBeNull = elementAtOrDefault([1, 2, 3], 10); // Will be null.const last = elementAtOrDefault([1, 2, 3], -1); // 3
TSource The type of the source iterable.
Returns the element at a specified index in a sequence or null if the index is out of range. A negative index can be used to get element starting from the end.