-
Notifications
You must be signed in to change notification settings - Fork 3
LastOrDefault
Yasser Moradi edited this page Aug 26, 2015
·
2 revisions
Description:
This method is similar to FirstOrDefault. But it returns last item.
Sample:
let items = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'];
let empty = [];
console.log(items.asEnumerable().lastOrDefault());
console.log(empty.asEnumerable().lastOrDefault());
console.log(items.asEnumerable().lastOrDefault(item => item.lenght == 5));
console.log(items.asEnumerable().lastOrDefault(item => item.lenght == 2));