In .NET i can do:
var ls = new List<string>(1,2,3,3,3,4,5,6);
var x1 = ls.Single(x => x == 3); // throws exception because there are more elems of 3 defined in ls
var x2 = ls.SingleOrDefault(x => x==3) // Returns default of int (0) because there are more elems of 3 defined in ls
var x3 = ls.Single(x => x== 1) // returns 1
Single documentation:
https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.single?view=netcore-3.1
What would be the Typescript equivalent?
I'm working in the latest version of Angular.