-
Notifications
You must be signed in to change notification settings - Fork 3
ElementAtOrDefault
Yasser Moradi edited this page Aug 26, 2015
·
2 revisions
Description:
This method is similar to ElementAt . However it returns null in case of either source is empty or index is out of range, instead of an exception.
Sample:
let empty = [];
let items = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'];
let elementAtOrDefault = items.asEnumerable().elementAtOrDefault(5);
console.log(elementAtOrDefault);
elementAtOrDefault = empty.asEnumerable().elementAtOrDefault(5);
console.log(elementAtOrDefault);