For filtering a list in C# we have :
var filteredList = List.Where(l => l.active);]
JS equivalent :
var filteredList = list.filter((l) => { return l.active == true; });
C# - Test for list values
var isListPopulated = List.Any( l => l.amount >= 0);
JS - Test for list values
var isListPopulated = list.filter((l) => { return l.amount >= 0; }).length > 0;
C# - Get first list item
var topItem = List.First( l => l.amount >= 0);
JS - Get first list item
var topItem = list.filter((l) => { return l.amount >= 0; })[0];
NB C# First() throws an exception if there is no match. As does the JS equivalent.
C# - Get first list item or null if none exist
var topItem = List.FirstOrDefault( l => l.amount >= 0);
JS - Get first list item or null if none exist (combo of the Any + First)
var filteredList = list.filter((l) => { return l.amount >= 0; });var topItem = filteredList.length > 0 ? filteredList[0] : null;